mono touch中处理json字符串

有不明白的地方欢迎入群 347636249 探讨

需要引用System.Json.dll文件:

private string jonstr=@"
			{
		    ""totalCount"": ""11"",
		    ""articleInfoList"": [{
		        ""Articleid"": ""134"",
		        ""Articletitle"": ""生态农业或成中央农村会议焦点"",
		        ""articleContent"": ""http://xxxxxxxxx/article/padarticle.aspx?id=134"",
		        ""Articlechannel"": ""80"",
		        ""Articlecreatedate"": ""2013/12/6 0:00:00"",
		        ""Articleimg"": """",
		        ""ArticleAuthor"": ""超级管理员"",
		        ""outline"": ""近日,中央就农业生态问题和农业可持续发展模式进行了密集调研,各级地方政府农业部门纷纷成立农村环境督查组对相关项目进行检查。多位权威专家在接受《经济参考报》记者采访时表示,一年一度的中央农村工作会议即将召开,预计生态农业将成为会议的一大焦点。"",
		        ""clicknumber"": ""71""
		    },
		    {
		        ""Articleid"": ""130"",
		        ""Articletitle"": ""中纪委今起开展网上党风廉政建设民意调查"",
		        ""articleContent"": ""http://xxxxxxxxxxx/article/padarticle.aspx?id=130"",
		        ""Articlechannel"": ""80"",
		        ""Articlecreatedate"": ""2013/11/8 0:00:00"",
		        ""Articleimg"": ""http://xxxxxxxxxxx/Fwadmin/Images/Attach/20131126151752777.jpg"",
		        ""ArticleAuthor"": ""超级管理员"",
		        ""outline"": """",
		        ""clicknumber"": ""16""
		    }]
		}";

说明:上面的json串并不标准,由于是直接复制的json字符串到编辑器中,Xamarin会自动转译,不过不会有影响,这里只是测试,自己测试下就知道,当然标准的json最好了。

private List<ArticleModel> parseJsonData()
		{
			JsonValue jv = JsonObject.Parse (jonstr);
			var rs = (from t in (JsonArray)jv ["articleInfoList"]
			        let r = t as JsonObject
			        select new ArticleModel {
				Articleid=t["Articleid"],
				Articletitle = t["Articletitle"],
				ArticleContent =t["articleContent"],
				Articlechannel = t["Articlechannel"],
				Articlecreatedate=t["Articlecreatedate"],
				Articleimg=t["Articleimg"],
				ArticleAuthor=t["ArticleAuthor"],
				Outline=t["outline"],
				ClickNumber = t["clicknumber"]
			}).ToList ();

			return rs;
		}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值