C#:Newtonsoft.Json将json字符串转换为实体对象
1.Json字符串:
{
"OptTypeList": [
[
{
"address": "宁波市鄞州区*****",
"divisionName": "********",
"tel": "010-12345678",
"divisionId": "813402",
"psummertime": "08:00",
"pwintertime": "18:00",
"streetId": "330212018"
},
{
"address": "宁波市鄞州区********",
"divisionName": "********",
"divisionId": "811904",
"streetId": "330212027"
}
]
],
"_TaskId": "53506a7943354748a1affdb9f635fb86",
"_Return": "000000",
"_ParentTaskId": "1f2bbefca759436a94017f55eed8512e"
}
2.打开网页,复制Json字符串,生成实体类
3.将生成的实体类加入项目代码;
4.引入Newtonsoft.Json.dll
Root root = JsonConvert.DeserializeObject<Root>(jsonString);