MXS&Vincene  ─╄OvЁ  &0000003 ─╄OvЁ  MXS&Vincene

MXS&Vincene  ─╄OvЁ:今天很残酷,明天更残酷,后天很美好,但是绝大部分人是死在明天晚上,只有那些真正的英雄才能见到后天的太阳。

MXS&Vincene  ─╄OvЁ:We're here to put a dent in the universe. Otherwise why else even be here?

正文>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

#region 获取json getaqi
protected string getaqi()
{
string url = "http://www.pm25.in/api/querys/pm2_5.json?city=无锡&token=5j1znBVAsnSf5xQyNQyq";
string r = string.Empty;
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url.ToString());
HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
//从Internet资源返回数据流
Stream webStream = webResponse.GetResponseStream();
//读取数据流
StreamReader webStreamReader = new StreamReader(webStream, System.Text.Encoding.UTF8);
//读取数据
r = webStreamReader.ReadToEnd();
webStreamReader.Close();
webStream.Close();
webResponse.Close();

return r;

}
#endregion

例如:  获取无锡某地PM2.5的值

[{"aqi":0,"area":"无锡","pm2_5":0,"pm2_5_24h":0,"position_name":"曹张","primary_pollutant":null,"quality":null,"station_code":"1190A","time_point":"2015-05-26T12:00:00Z"},{"aqi":67,"area":"无锡","pm2_5":28,"pm2_5_24h":33,"position_name":"漆塘","primary_pollutant":"颗粒物(PM10)","quality":"良","station_code":"1191A","time_point":"2015-05-26T12:00:00Z"},{"aqi":61,"area":"无锡","pm2_5":30,"pm2_5_24h":44,"position_name":"东亭","primary_pollutant":"颗粒物(PM10)","quality":"良","station_code":"1192A","time_point":"2015-05-26T12:00:00Z"},{"aqi":67,"area":"无锡","pm2_5":27,"pm2_5_24h":42,"position_name":"旺庄","primary_pollutant":"颗粒物(PM10)","quality":"良","station_code":"1193A","time_point":"2015-05-26T12:00:00Z"},{"aqi":71,"area":"无锡","pm2_5":32,"pm2_5_24h":52,"position_name":"堰桥","primary_pollutant":"颗粒物(PM10)","quality":"良","station_code":"1195A","time_point":"2015-05-26T12:00:00Z"},{"aqi":61,"area":"无锡","pm2_5":30,"pm2_5_24h":39,"position_name":"雪浪","primary_pollutant":"颗粒物(PM10)","quality":"良","station_code":"1188A","time_point":"2015-05-26T12:00:00Z"},{"aqi":70,"area":"无锡","pm2_5":42,"pm2_5_24h":46,"position_name":"黄巷","primary_pollutant":"颗粒物(PM10)","quality":"良","station_code":"1189A","time_point":"2015-05-26T12:00:00Z"},{"aqi":74,"area":"无锡","pm2_5":32,"pm2_5_24h":38,"position_name":"荣巷","primary_pollutant":"颗粒物(PM10)","quality":"良","station_code":"1194A","time_point":"2015-05-26T12:00:00Z"},{"aqi":68,"area":"无锡","pm2_5":31,"pm2_5_24h":42,"position_name":null,"primary_pollutant":"颗粒物(PM10)","quality":"良","station_code":null,"time_point":"2015-05-26T12:00:00Z"}]

获取 JArray 中某一个值如下:

JArray jo = (JArray)JsonConvert.DeserializeObject(getaqi());

string aqi = jo[1]["aqi"].ToString();
string quality = jo[1]["quality"].ToString();

结果:aqi="67";  quality="良";

JArray获取元素值的更多相关文章

  1. jQuery获取元素值以及设置元素值总结

    html(): 1:用户获取元素内的HTML内容,如果元素包含子标签,会以整体的形式返回 2:只获取第一个元素的内容 3:只获取普通元素的内容,表单元素内容无法获取 html(val): 1:用来设置 ...

  2. Selenium2学习-028-WebUI自动化实战实例-026-获取页面元素值或者元素属性值

    在自动化脚本编写过程中,经常需要获取页面元素的文本进行判断,以便对于不同的文本进行不同的处理.比如:很多的购物网站,加入购物车的按钮是有多个状态的(加入购物车.到货通知.暂不销售等),那么在实际的操作 ...

  3. JS获取元素CSS值

    一.getComputedStyle getComputedStyle 是一个可以获取当前元素所有最终使用的CSS属性值.返回的是一个CSS样式声明对象([object CSSStyleDeclara ...

  4. jquery 获取一组元素的选中项 - 函数、jquery获取复选框值、jquery获取单选按钮值

    做表单提交时,如果现在还在用form提交,用户体验很差,所以一般使用ajax提交. 其中需要获取每个表单输入元素的值,获取的时候像文本框这些还好说,Jquery提供了 .val() 方法,获取很方便, ...

  5. JS获取元素CSS值的各种方法分析

    先来看一个实例:如何获取一个没有设置大小的字体? <!DOCTYPE html> <html lang="en"> <head> <met ...

  6. 获取元素CSS值之getComputedStyle方法熟悉

    by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=2378 一.碎碎念~前 ...

  7. [转载]jquery获取元素索引值index()方法:

    jquery的index()方法 搜索匹配的元素,并返回相应元素的索引值,从0开始计数. 如果不给 .index() 方法传递参数,那么返回值就是这个jQuery对象集合中第一个元素相对于其同辈元素的 ...

  8. jquery获取元素索引值index()方法

    jquery的index()方法 搜索匹配的元素,并返回相应元素的索引值,从0开始计数. 如果不给 .index() 方法传递参数,那么返回值就是这个jQuery对象集合中第一个元素相对于其同辈元素的 ...

  9. 利用getComputedStyle方法获取元素css的属性值

    在平时的工作中有时候会碰到需要获取元素当前样式的问题,查了一下可以用getComputedStyle这个方法来获取元素计算后的样式(有些我们在css里面没有写的,浏览器默认的样式也可以获得) getC ...

随机推荐

  1. Fckeditor使用方法

    下载地址 http://ckeditor.com/download <?php require('../fckeditor/fckeditor.php'); ?> <html> ...

  2. Python安装distribute包

    从官网https://pypi.python.org/pypi/distribute/0.6.49#downloads上下载distribute包,解压后进入解压文件的目录下,使用 python se ...

  3. java基础之吃货联盟

    因为用的是普通数组,所以编写的代码可能比较长,而且有的功能还比较不健全,代码如下: 0.定义数组(因为用static修饰可以不用New,比较方便,但可能比较损耗性能) //订餐人名字 static S ...

  4. jQuery实现页面锚点滚动效果

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  5. html5——:hover事件触发自己的:afert伪元素事件

    :hover事件触发自己的:afert伪元素事件中间是没有空格的

  6. Tcl之looping

    1 While loop while test body The while command evaluates test as an expression. If test is true, the ...

  7. (转)淘淘商城系列——初始SolrCloud

    http://blog.csdn.net/yerenyuan_pku/article/details/72944611 本文我只是简单介绍一下SolrCloud,如果大家要是感兴趣的话,可以参考Sol ...

  8. hibernate+struts2

    一.环境 添加struts2和hibernate的jar包.创建web.xml(配置struts的过滤器).struts2.xml和hibernate.cfg.xml(设置一些数据库参数). 二.创建 ...

  9. VBA中Option的四种用法

    1.Option Explicit.当使用Option Explicit时,必须在模块中的所有过程声明每一个变量,否则会出现语法错误并不能被编译.这样做的好处是,它能消除程序中因为错拼变量名而导致程序 ...

  10. js的hex转base64

    if (!window.atob) { var tableStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456 ...