首页 新闻 会员 周边

json序列化问题

0
悬赏园豆:5 [已解决问题] 解决于 2017-12-19 11:19




json序列化问题

 

这种java方面转过来的json. 在net下怎么设置实体对象.

 

 

复制代码
{
  "status": "1",
  "traces": [
    {
      "2222222": {
        "waybill_no": "1231232131",
        "status": 1,
        "list": [
          {
            "time": "2017-11-25 20:43",
            "place_id": "15"
          },
          {
            "time": "2017-11-29 16:26",
            "place_id": "16"
          }
        ]
      },
      "123123123": {
        "waybill_no": "1231232131",
        "status": 1,
        "list": [
          {
            "time": "2017-11-25 20:43",
            "place_id": "15"
          },
          {
            "time": "2017-11-29 16:26",
            "place_id": "16"
          }
        ]
      }
    }
  ]
}
复制代码
问题补充:
        public class DestResultInfo
        {
            public string status { get; set; }
            public Dictionary<string, DestOrderTrackInfo>[] traces { get; set; }
        }

        public class DestOrderTrackInfo
        {
            public int status { get; set; }
            public string waybill_no { get; set; }
            public DestOrderTrackListInfo[] list { get; set; }
        }

        public class DestOrderTrackListInfo
        {
            public string time { get; set; }
            public string place { get; set; }
            public string place_id { get; set; }
        }

解决了. 这个结构怪的很.

colvinliu的主页 colvinliu | 初学一级 | 园豆:6
提问于:2017-12-19 11:06
< >
分享
最佳答案
0

赋值json字符串,在vs里.新建一个cs页面.点击->菜单栏->编辑->选择性粘贴->将json粘贴为类

收获园豆:5
吴瑞祥 | 高人七级 |园豆:29449 | 2017-12-19 11:13

这个不行.  注意看. 属性名称是变化的.

colvinliu | 园豆:6 (初学一级) | 2017-12-19 11:14

@colvinliu: 属性名变化的情况当然是键值对啦.

吴瑞祥 | 园豆:29449 (高人七级) | 2017-12-19 11:14
其他回答(1)
0

 public class A{ public string time{get;set;}}

public class B

{

   public string waybill_no{get;set;}

   public int status {get;set;}

   public List<A> list{get;set;}

}

public class C{

   public string status{get;set;}

   public Dictionary<string ,B> traces {get;set;}

}

西漠以西 | 园豆:1675 (小虾三级) | 2017-12-19 11:22

感谢. 已经解决了.

支持(0) 反对(0) colvinliu | 园豆:6 (初学一级) | 2017-12-19 11:23
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册