json 数据如下:

{"success":"true","errorCode":"200","errorDescribe":"",
"data":[
{"key":{"sys_time":0,"user_name":1,"jingdu":2,"weidu":3,"ljingdu":4,"lweidu":5,"datetime":6,"heart_time":7,"su":8,"status":9,"hangxiang":10,"sim_id":11,
"user_id":12,"sale_type":13,"iconType":14,"server_time":15,"product_type":16,"expire_date":17,"group_id":18,"statenumber":19,
"electric":20,"describe":21,"sim":22,"precision":23,"isFollow":24,"plateNumber":25,"auth":26,"authList":27,"deptname":28},
"records":[[1663751663000,"T80806466303",118.12762611,24.49420997,118.12762611,24.49420997,1663740167141,1663751665046,"0","001000100",170.0,"82706466303","f8befead3aeb4774a7a587ecdcb40aa4",0,"09",
1663751799258,"T808",2292710400000,"0","925.178,0,0,,33,0,0,22,0,1,0,0,0,0,28.000,1,0,,Parking,0",33.0,"设备信息:W100_V1.05s;LTE:23;GB:1,1;M2:30,300;B:3.84,ICCID:89860318245921992912","",0,"0","","0","",
"厦门某某公司"]],
"groups":[],"followCount":0,"deviceCount":1,"msg":""}]}

反序列化操作:

模型类建立
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc.Web
{
public class AccessHelper
{
public string id { get; set; }
public string mds { get; set; }
public bool success { get; set; }
public string errorCode { get; set; }
public string errorDescribe { get; set; }
public List<DataHelper> data { get; set; }
}
public class DataHelper
{
public sonHelper key { get; set; }
public List<object> records { get; set; }
public int followCount { get; set; }
public List<object> groups { get; set; }
public int deviceCount { get; set; }
public string msg { get; set; }

}
public class sonHelper
{
public long sys_time { get; set; }
public int user_name { get; set; }
public int jingdu { get; set; }
public int weidu { get; set; }
public int ljingdu { get; set; }
public int lweidu { get; set; }
public int datetime { get; set; }
public int heart_time { get; set; }
public int su { get; set; }
public int status { get; set; }
public int hangxiang { get; set; }
public int sim_id { get; set; }
public int user_id { get; set; }
public int sale_type { get; set; }
public int server_time { get; set; }
public int iconType { get; set; }
public int product_type { get; set; }
public int statenumber { get; set; }
public int group_id { get; set; }
public int expire_date { get; set; }
public int electric { get; set; }
public int describe { get; set; }
public int sim { get; set; }
public int precision { get; set; }
public int isFollow { get; set; }
public int plateNumber { get; set; }
public int auth { get; set; }
public int authList { get; set; }
public int deptname { get; set; }
}

}
View Code

//数据反序列化 

AccessHelper obj = JsonConvert.DeserializeObject<AccessHelper>(returnXml);

posted on 2022-09-22 10:16  我炒菜不放盐  阅读(11)  评论(0编辑  收藏  举报