windows phone:解析json数据(使用json.Net)
来源:互联网 发布:p2psearcher 百度软件 编辑:程序博客网 时间:2024/04/27 20:13
转载于 http://blog.csdn.net/fengyun1989/article/details/7326557
要解析类似以下如此数据:
{"weatherinfo":{"city":"长安","cityid":"101110102","temp":"7","WD":"西风","WS":"1级","SD":"50%","WSE":"1","time":"18:40","isRadar":"0","Radar":""}}
创建了那么两个类供解析后存放数据用。
class WhetherInfo { public string city { get; set; } public string temp { get; set; } public string cityid { get; set; } public string WD { get; set; } public string WS { get; set; } public string SD { get; set; } public string WSE { get; set; } public string time { get; set; } public string isRader { get; set; } public string Rader { get; set; } } class Info { public WhetherInfo weatherinfo { get; set; } }
一开始考虑用DataContractJsonSerializer类,但是使用时候报securityException错误。。研究半天,无果。好像是这个类不支持解析如此复杂的json。
后来发现有个叫json.NET这个库。JSON.NET官网
里面有个叫LINQ TO JSON。貌似支持解析如此数据。
首先添加下载下来的的Newtonsoft.Json.dll添加进来。
添加代码:
using Newtonsoft.Json;using Newtonsoft.Json.Linq;
依然解析以让数据。
JObject json = JObject.Parse(e.Result); Info info = new Info { weatherinfo = new WhetherInfo {//
//由上面需要解析的数据可知,我们需要的数据在在weatherinfo这个节点的下一个节点
成功!
不过要把解析出来的对象一个一个赋值还真是麻烦。。。
- windows phone:解析json数据(使用json.Net)
- Windows Phone开发之Json数据解析
- windows phone 中的 json解析
- .Net解析JSON数据
- 使用Json解析Json数据
- windows phone开发之json解析篇
- Window Phone 7 解析 Json 数据
- <WP7>解析json数据(初用json.Net)
- asp.net 解析json数据
- .net 解析json格式数据
- 【C#】使用Json.NET(newtonsoft)解析Json
- Java解析JSON数据 使用org.json
- 使用json-lib解析json数据
- 使用JsonCPP解析JSON数据(VC++)
- 使用jsoncpp解析JSON数据(转)
- Windows Phone 7开发遇到的事:解析JSON
- 使用jQuery解析JSON数据
- 使用jQuery解析JSON数据
- dwg缩略图和图标
- [ jQuery ] jQuery.fn和jQuery.prototype区别!
- Linux平台设备驱动
- 第六堂课后作业
- echo 出现乱码
- windows phone:解析json数据(使用json.Net)
- spring-mvc入门(一):入门实例
- freemarker struts2 radio标签默认选中
- WDA程序的国际化(多语言文本的实现)
- phonegap整合调用dwr实例,web应用轻松变身移动APP
- 使用UIWebView加载网页
- linux 资源消耗分析
- 吃货的胜利:世界最古老的食物(7P)
- 推荐系统