[{"aqi":88,"area":"北京","pm2_5":62,"pm2_5_24h":108,"position_name":"万寿西宫","primary_pollutant":"颗粒物(PM10)","quality":"良","station_code":"1001A","time_point":"2015-03-26T16:00:00Z"},{"aqi":109,"area":"北京","pm2_5":82,"pm2_5_24h":117,"position_name":"定陵","primary_pollutant":"细颗粒物(PM2.5)","quality":"轻度污染","station_code":"1002A","time_point":"2015-03-26T16:00:00Z"},{"aqi":103,"area":"北京","pm2_5":72,"pm2_5_24h":110,"position_name":"东四","primary_pollutant":"颗粒物(PM10)","quality":"轻度污染","station_code":"1003A","time_point":"2015-03-26T16:00:00Z"},{"aqi":97,"area":"北京","pm2_5":72,"pm2_5_24h":102,"position_name":"天坛","primary_pollutant":"细颗粒物(PM2.5)","quality":"良","station_code":"1004A","time_point":"2015-03-26T16:00:00Z"},{"aqi":235,"area":"北京","pm2_5":185,"pm2_5_24h":117,"position_name":"农展馆","primary_pollutant":"细颗粒物(PM2.5)","quality":"重度污染","station_code":"1005A","time_point":"2015-03-26T16:00:00Z"},{"aqi":97,"area":"北京","pm2_5":72,"pm2_5_24h":109,"position_name":"官园","primary_pollutant":"细颗粒物(PM2.5)","quality":"良","station_code":"1006A","time_point":"2015-03-26T16:00:00Z"},{"aqi":90,"area":"北京","pm2_5":67,"pm2_5_24h":110,"position_name":"海淀区万柳","primary_pollutant":"细颗粒物(PM2.5)","quality":"良","station_code":"1007A","time_point":"2015-03-26T16:00:00Z"},{"aqi":93,"area":"北京","pm2_5":69,"pm2_5_24h":120,"position_name":"顺义新城","primary_pollutant":"细颗粒物(PM2.5)","quality":"良","station_code":"1008A","time_point":"2015-03-26T16:00:00Z"},{"aqi":119,"area":"北京","pm2_5":90,"pm2_5_24h":123,"position_name":"怀柔镇","primary_pollutant":"细颗粒物(PM2.5)","quality":"轻度污染","station_code":"1009A","time_point":"2015-03-26T16:00:00Z"},{"aqi":135,"area":"北京","pm2_5":50,"pm2_5_24h":110,"position_name":"昌平镇","primary_pollutant":"颗粒物(PM10)","quality":"轻度污染","station_code":"1010A","time_point":"2015-03-26T16:00:00Z"},{"aqi":97,"area":"北京","pm2_5":72,"pm2_5_24h":111,"position_name":"奥体中心","primary_pollutant":"细颗粒物(PM2.5)","quality":"良","station_code":"1011A","time_point":"2015-03-26T16:00:00Z"},{"aqi":87,"area":"北京","pm2_5":64,"pm2_5_24h":118,"position_name":"古城","primary_pollutant":"细颗粒物(PM2.5)","quality":"良","station_code":"1012A","time_point":"2015-03-26T16:00:00Z"},{"aqi":106,"area":"北京","pm2_5":79,"pm2_5_24h":112,"position_name":null,"primary_pollutant":"颗粒物(PM2.5)","quality":"轻度污染","station_code":null,"time_point":"2015-03-26T16:00:00Z"}]
------解决思路----------------------
private void Des()
{
string jsonStr = @"[{""aqi"":88,""area"":""北京"",""pm2_5"":62,""pm2_5_24h"":108,""position_name"":""万寿西宫"",""primary_pollutant"":""颗粒物(PM10)"",""quality"":""良"",""station_code"":""1001A"",""time_point"":""2015-03-26T16:00:00Z""},{""aqi"":109,""area"":""北京"",""pm2_5"":82,""pm2_5_24h"":117,""position_name"":""定陵"",""primary_pollutant"":""细颗粒物(PM2.5)"",""quality"":""轻度污染"",""station_code"":""1002A"",""time_point"":""2015-03-26T16:00:00Z""},{""aqi"":103,""area"":""北京"",""pm2_5"":72,""pm2_5_24h"":110,""position_name"":""东四"",""primary_pollutant"":""颗粒物(PM10)"",""quality"":""轻度污染"",""station_code"":""1003A"",""time_point"":""2015-03-26T16:00:00Z""},{""aqi"":97,""area"":""北京"",""pm2_5"":72,""pm2_5_24h"":102,""position_name"":""天坛"",""primary_pollutant"":""细颗粒物(PM2.5)"",""quality"":""良"",""station_code"":""1004A"",""time_point"":""2015-03-26T16:00:00Z""},{""aqi"":235,""area"":""北京"",""pm2_5"":185,""pm2_5_24h"":117,""position_name"":""农展馆"",""primary_pollutant"":""细颗粒物(PM2.5)"",""quality"":""重度污染"",""station_code"":""1005A"",""time_point"":""2015-03-26T16:00:00Z""},{""aqi"":97,""area"":""北京"",""pm2_5"":72,""pm2_5_24h"":109,""position_name"":""官园"",""primary_pollutant"":""细颗粒物(PM2.5)"",""quality"":""良"",""station_code"":""1006A"",""time_point"":""2015-03-26T16:00:00Z""},{""aqi"":90,""area"":""北京"",""pm2_5"":67,""pm2_5_24h"":110,""position_name"":""海淀区万柳"",""primary_pollutant"":""细颗粒物(PM2.5)"",""quality"":""良"",""station_code"":""1007A"",""time_point"":""2015-03-26T16:00:00Z""},{""aqi"":93,""area"":""北京"",""pm2_5"":69,""pm2_5_24h"":120,""position_name"":""顺义新城"",""primary_pollutant"":""细颗粒物(PM2.5)"",""quality"":""良"",""station_code"":""1008A"",""time_point"":""2015-03-26T16:00:00Z""},{""aqi"":119,""area"":""北京"",""pm2_5"":90,""pm2_5_24h"":123,""position_name"":""怀柔镇"",""primary_pollutant"":""细颗粒物(PM2.5)"",""quality"":""轻度污染"",""station_code"":""1009A"",""time_point"":""2015-03-26T16:00:00Z""},{""aqi"":135,""area"":""北京"",""pm2_5"":50,""pm2_5_24h"":110,""position_name"":""昌平镇"",""primary_pollutant"":""颗粒物(PM10)"",""quality"":""轻度污染"",""station_code"":""1010A"",""time_point"":""2015-03-26T16:00:00Z""},{""aqi"":97,""area"":""北京"",""pm2_5"":72,""pm2_5_24h"":111,""position_name"":""奥体中心"",""primary_pollutant"":""细颗粒物(PM2.5)"",""quality"":""良"",""station_code"":""1011A"",""time_point"":""2015-03-26T16:00:00Z""},{""aqi"":87,""area"":""北京"",""pm2_5"":64,""pm2_5_24h"":118,""position_name"":""古城"",""primary_pollutant"":""细颗粒物(PM2.5)"",""quality"":""良"",""station_code"":""1012A"",""time_point"":""2015-03-26T16:00:00Z""},{""aqi"":106,""area"":""北京"",""pm2_5"":79,""pm2_5_24h"":112,""position_name"":null,""primary_pollutant"":""颗粒物(PM2.5)"",""quality"":""轻度污染"",""station_code"":null,""time_point"":""2015-03-26T16:00:00Z""}]";
var result = JsonConvert.DeserializeObject<List<TempClass>>(jsonStr);
}
class TempClass
{
public int aqi { get; set; }
public string area { get; set; }
public int pm2_5 { get; set; }
public int pm2_5_24h { get; set; }
public string position_name { get; set; }
public string primary_pollutant { get; set; }
public string quality { get; set; }
public string station_code { get; set; }
public DateTime time_point { get; set; }
}
需要用到第三方控件
using Newtonsoft.Json;
------解决思路----------------------
我有 一个 自写自用的json库 楼主看能用得着不
http://pan.baidu.com/s/1sjr2jTF
网盘里面下载 wnxd.javascript.dll
然后项目中 引用后
using wnxd.javascript
json json = new json("json字符串"); //就OK了
调用方式:
例如 楼主贴的 json字符串 最外层 是 数组
即 json[0] 可取到 第一个成员
然后接下来一层是 对象
可用 json[0].aqi ( 或 json[0]["aqi"] ) 取到 88 的 json对象 ( 取值是用 json[0].aqi.Value )
其中 json.length 可获取 数组成员数 json.count 可获取 对象成员数 对象跟数组 都支持枚举
json.GetType() 可判断 json类型 array,object,string,number,bool,function,null,undefined 这几种类型
json.ToString() 可获取 完整的 json字符串
本 json库 是仿照 js 语法写的 可能部分专攻C#的人 用的很别扭
还有其他方便的功能... 自行摸索 或者 咨询我吧.(514543271)