以 JSON 格式在 DevExpress Grid 中显示数据

问题描述

我有一个 JSON 格式的数据,需要在网格控件中显示。该 JSON 数据如果有一个数组,那么它会在网格中正确显示并带有 (+) 符号以进行扩展,但如果它有一个包含其成员的对象,那么它只会显示为带有其类 ID 的列。

如果类对象在数组中,则显示如下:

enter image description here

如果类对象只是单个对象,则显示如下:

enter image description here

我的 JSON 字符串如下:

[
    {
        "customerID" : "AROUT","companyName" : "Around the Horn","contactName" : "Thomas Hardy","contactTitle" : "Sales Representative","address" : {
            "street" : "120 Hanover Sq.","city" : "London","region" : "NULL","postalCode" : "WA1 1DP","country" : "UK","phone" : "(171) 555-7788"
        }
    },{
        "customerID" : "BERGS","companyName" : "Berglunds snabbköp","contactName" : "Christina Berglund","contactTitle" : "Order Administrator","address" : {
            "street" : "Berguvsvägen  8","city" : "Luleå","postalCode" : "S-958 22","country" : "Sweden","phone" : "0921-12 34 65"
        }
    },{
        "customerID" : "BLAUS","companyName" : "Blauer See Delikatessen","contactName" : "Hanna Moos","address" : {
            "street" : "Forsterstr. 57","city" : "Mannheim","postalCode" : 68306,"country" : "Germany","phone" : "0621-08460"
        }
    }   
]

我已经在 Grid 中加载了字符串,如下所示:

string jsonString = File.ReadAllText(@"D:\Data.txt");            

JsonDataSource jsonDataSource = new JsonDataSource();
jsonDataSource.JsonSource = new CustomJsonSource(jsonString);
jsonDataSource.Fill();

gridControl1.DataSource = jsonDataSource;

如果数据只在单个对象中接收,那么如何将带有(+)号的地址显示为扩展?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...