#region Get JSON Getaqi
protected String Getaqi ()
{
string url = "http://www.pm25.in/api/querys/pm2_5.json?city= wuxi &token=5j1znbvasnsf5xqynqyq";
string r = String. Empty;
HttpWebRequest webRequest = (HttpWebRequest) webrequest.create (URL. ToString ());
HttpWebResponse WebResponse = (HttpWebResponse) webrequest.getresponse ();
//Return data flow from Internet resources
Stream webstream = WebResponse.GetResponseStream ();
//Read data stream
StreamReader webstreamreader = new StreamReader (Webstream, System.Text.Encoding.UTF8);
//Read Data
r = webstreamreader.readtoend ();
webstreamreader.close ();
webstream.close ();
webresponse.close ();
return R;
}
#endregion
For example: Get the value of PM2.5 somewhere in Wuxi
[{"AQI": 0, "area": "Wuxi", "Pm2_5": 0, "pm2_5_24h": 0, "position_name": "Cao Zhang", "primary_pollutant": null, "quality": null, " Station_code ":" 1190A "," Time_point ":" 2015-05-26t12:00:00z "},{" AQI ":" Area ":" Wuxi "," Pm2_5 ":" pm2_5_24h ": 33," Position_name ":" Lacquer Pond "," primary_pollutant ":" Particulate matter (PM10) "," Quality ":" Liang "," Station_code ":" 1191A "," Time_point ":" 2015-05-26t12:00:00z "},{" AQI ":", "area": "Wuxi", "Pm2_5":, "pm2_5_24h": "Position_name": "East Pavilion", "primary_pollutant ":" Particulate matter (PM10) "," Quality ":" Good "," Station_code ":" 1192A "," Time_point ":" 2015-05-26t12:00:00z "},{" AQI ":," area ":" Wuxi ", "Pm2_5": "pm2_5_24h": "Position_name": "Wang Zhuang", "primary_pollutant": "Particulate matter (PM10)", "Quality": "Liang", "Station_code": " 1193A "," Time_point ":" 2015-05-26t12:00:00z "},{" AQI ": +," area ":" Wuxi "," pm2_5 ": +," pm2_5_24h ":," Position_name ":" Yan Qiao "," primary_pollutant ":" Particulate matter (PM10) "," Quality ":" Good "," Station_code ":" 1195A "," Time_point ":" 2015-05-26t12:00:00z "}, {"AQI": "Area": "Wuxi", "Pm2_5": "pm2_5_24h": "Position_name": "Snow Wave", "primary_pollutant": "Particulate matter (PM10)", "quality" : "Liang", "Station_code": "1188A "," Time_point ":" 2015-05-26t12:00:00z "},{" AQI ": +," area ":" Wuxi "," Pm2_5 ":," pm2_5_24h ": $," position_name ":" Huang Xiang " , "primary_pollutant": "Particulate matter (PM10)", "Quality": "Good", "Station_code": "1189A", "Time_point": "2015-05-26t12:00:00z"},{" AQI ":", "area": "Wuxi", "Pm2_5": "pm2_5_24h": "Position_name": "Rong Xiang", "primary_pollutant": "Particulate matter (PM10)", "Quality": " Good "," Station_code ":" 1194A "," Time_point ":" 2015-05-26t12:00:00z "},{" AQI ":," area ":" Wuxi "," pm2_5 ": +," pm2_5_24h ": 42 , "Position_name": null, "primary_pollutant": "Particulate matter (PM10)", "Quality": "Benign", "station_code": null, "Time_point": " 2015-05-26t12:00:00z "}]
Get a value in Jarray as follows:
Jarray Jo = (jarray) jsonconvert.deserializeobject (Getaqi ());
String AQI = jo[1]["AQI"]. ToString ();
String quality = jo[1]["quality"]. ToString ();
Results: aqi= "67"; Quality= "Liang";
Jarray Get element values