C# json解析(多层)怎么遍历
{"resultcode":"200","reason":"成功的返回","result":{"BJ":{"province":"北京","province_code":...
{"resultcode":"200","reason":"成功的返回","result":
{"BJ":
{"province":"北京","province_code":"BJ","citys":
[{"city_name":"北京","city_code":"BJ","abbr":"京","engine":"1","engineno":"0","classa":"0","class":"0","classno":"0","regist":"0","registno":"0"}]},
"SH":{"province":"上海","province_code":"SH","citys":[{"city_name":"上海","city_code":"SH","abbr":"沪","engine":"1","engineno":"0","classa":"0","class":"0","classno":"0","regist":"0","registno":"0"}]},
"ZJ":{"province":"浙江","province_code":"ZJ","citys":[{"city_name":"杭州","city_code":"ZJ_HZ","abbr":"浙","engine":"0","engineno":"0","classa":"1","class":"1","classno":"6","regist":"0","registno":"0"},{"city_name":"宁波","city_code":"ZJ_NB","abbr":"浙","engine":"0","engineno":"0","classa":"1","class":"1","classno":"6","regist":"0","registno":"0"},{"city_name":"义乌","city_code":"ZJ_YW","abbr":"浙","engine":"0","engineno":"0","classa":"1","class":"1","classno":"3","regist":"0","registno":"0"}]),"error_code":0}
使用JsonSerializer或者JavaScriptSerializer取每个节点的值
使用对象获取 展开
{"BJ":
{"province":"北京","province_code":"BJ","citys":
[{"city_name":"北京","city_code":"BJ","abbr":"京","engine":"1","engineno":"0","classa":"0","class":"0","classno":"0","regist":"0","registno":"0"}]},
"SH":{"province":"上海","province_code":"SH","citys":[{"city_name":"上海","city_code":"SH","abbr":"沪","engine":"1","engineno":"0","classa":"0","class":"0","classno":"0","regist":"0","registno":"0"}]},
"ZJ":{"province":"浙江","province_code":"ZJ","citys":[{"city_name":"杭州","city_code":"ZJ_HZ","abbr":"浙","engine":"0","engineno":"0","classa":"1","class":"1","classno":"6","regist":"0","registno":"0"},{"city_name":"宁波","city_code":"ZJ_NB","abbr":"浙","engine":"0","engineno":"0","classa":"1","class":"1","classno":"6","regist":"0","registno":"0"},{"city_name":"义乌","city_code":"ZJ_YW","abbr":"浙","engine":"0","engineno":"0","classa":"1","class":"1","classno":"3","regist":"0","registno":"0"}]),"error_code":0}
使用JsonSerializer或者JavaScriptSerializer取每个节点的值
使用对象获取 展开
展开全部
想用JavaScriptSerializer,前提条件就是你的json数据要有对应的Domain类。
如果没有,你只能转换为Dictionary,然后在转换。
如果没有,你只能转换为Dictionary,然后在转换。
更多追问追答
追问
我查到JavaScriptSerializer好像有限制的,是否有例子可以参考或者代码
追答
我不明白你现在遇到的问题。你是对JavaScriptSerializer这个类没用过,还是什么?
这个类的使用非常简单。
http://www.cnblogs.com/color-wolf/p/3640261.html
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询