easyUI这样获取Json的内嵌数据

先给出返回的json数据。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{
"total":3,
"rows":[
        { "mobile":"13788888888",
          "certificateCode":"370682xxxxxxxxxxxx",
          "account":{
                         "realName":"刘德华",
                         "mobile":null,
                         "certificateCode":"370682xxxxxxxxxxxx",
                         "certificateType":"身份证",
                         "accountType":"教工",
                         "gender":"男",
                         "address":"青岛校区\\网络管理中心",
                         "name":"0701468004",
                         "id":37932
                    },
          "externalAccess":true,
          "opTime":1314673484000,
          "wlan":{
                    "name":"移动",
                    "id":1
                 },
          "interAccess":true,
          "id":19
         }
       ]
}

昨天遇到这样一个问题,在取account里面的信息时,我使用了 如下的方式:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
     field: 'account',
     title: '真实姓名',
     width: 60,
     formatter: function (value, rec) {
         return rec.account.realName;
     }
 }, {
     field: 'account',
     title: '账号类型',
     width: 60,
     formatter: function (value, rec) {
         return rec.account.accountType;
     }
 }, {
     field: 'account',
     title: '性别',
     width: 50,
     formatter: function (value, rec) {
         return rec.account.gender;
     }
 }

这样可以取出realName的值,但是账号类型,性别也显示realName的值。不知道问题出在哪,在网上搜索,看到给出的解决办法都是返回 rec.account.realName这样,但是只返回一个字段,这样肯定可以返回正确的值了,但是我要返回的是很多个字段。真是没办法了,就随便试试吧,我把field:’account’改成field:’account.realName’,再运行一次,竟然得到了我想要的结果。

下面是完整的代码:

最后运行效果如下:

posted @   BobTian  阅读(22078)  评论(0编辑  收藏  举报
编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· 字符编码:从基础到乱码解决
· Open-Sora 2.0 重磅开源!
点击右上角即可分享
微信分享提示