请选择 进入手机版 | 继续访问电脑版

马上加入IBC程序猿 各种源码随意下,各种教程随便看! 注册 每日签到 加入编程讨论群

C#教程 ASP.NET教程 C#视频教程程序源码享受不尽 C#问题入口 ASP.NET问题入口

【C#问题提交】 社群合作 申请版主 程序开发 【远程协助】 每天乐一乐 每日签到 【承接毕业设计】 面试-葵花宝典下载

官方一群:

官方二群:

查看: 523|回复: 7

[求助] json数据解析

  [复制链接]

该用户从未签到

7

主题

12

帖子

69

积分

注册会员

Rank: 2

积分
69
发表于 2020-5-29 15:02:47 | 显示全部楼层 |阅读模式

马上加入IBC,查看更多教程

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
从api返回的json数据,如何读取自己需要的数据,比如图片的json格式,我想读取pm2.5和pm10的值
[C#] 纯文本查看 复制代码
{
                  "showapi_res_error": "",
                  "showapi_res_id": "6cb96fedf90a486da298b139ffbea99f",
                  "showapi_res_code": 0,
                  "showapi_res_body": {"ret_code":0,"showapi_fee_code":-1,"pm":{"so2":"8","o3":"42","area_code":"tianjin","pm2_5":"30","ct":"2019-12-13 16:00:42.793","primary_pollutant":"颗粒物(PM10)","co":"0.6","num":"83","area":"天津","no2":"35","aqi":"51","quality":"良好","pm10":"51","o3_8h":"33"},"siteList":[{"co":"1.2","so2":"22","o3":"32","no2":"62","aqi":"107","quality":"轻度污染","pm10":"119","pm2_5":"80","site_name":"广安道","o3_8h":"14","primary_pollutant":"-","ct":"2019-12-13 15:03:29.194"},{"co":"0.7","so2":"13","o3":"32","no2":"50","aqi":"84","quality":"良好","pm10":"55","pm2_5":"62","site_name":"永明路","o3_8h":"11","primary_pollutant":"PM2.5","ct":"2019-12-13 15:03:29.602"},{"co":"0.8","so2":"12","o3":"32","no2":"53","aqi":"82","quality":"良好","pm10":"-","pm2_5":"60","site_name":"海泰发展二路","o3_8h":"38","primary_pollutant":"-","ct":"2019-12-13 15:03:29.621"},{"co":"0.7","so2":"14","o3":"24","no2":"50","aqi":"82","quality":"良好","pm10":"66","pm2_5":"60","site_name":"塘沽营口道","o3_8h":"9","primary_pollutant":"-","ct":"2019-12-13 15:03:29.634"},{"co":"0.4","so2":"6","o3":"43","no2":"27","aqi":"82","quality":"良好","pm10":"75","pm2_5":"60","site_name":"滨水东路","o3_8h":"17","primary_pollutant":"-","ct":"2019-12-13 15:03:29.652"},{"co":"0.7","so2":"12","o3":"36","no2":"45","aqi":"77","quality":"良好","pm10":"68","pm2_5":"56","site_name":"汉北路","o3_8h":"12","primary_pollutant":"PM2.5","ct":"2019-12-13 15:03:29.661"},{"co":"0.9","so2":"14","o3":"28","no2":"49","aqi":"75","quality":"良好","pm10":"72","pm2_5":"55","site_name":"第四大街","o3_8h":"12","primary_pollutant":"PM2.5","ct":"2019-12-13 15:03:29.666"},{"co":"0.7","so2":"23","o3":"25","no2":"54","aqi":"73","quality":"良好","pm10":"72","pm2_5":"53","site_name":"团泊洼(对照点)","o3_8h":"11","primary_pollutant":"PM2.5","ct":"2019-12-13 15:03:29.673"},{"co":"0.7","so2":"13","o3":"36","no2":"44","aqi":"69","quality":"良好","pm10":"69","pm2_5":"50","site_name":"河西一经路(启用150702)","o3_8h":"16","primary_pollutant":"PM2.5","ct":"2019-12-13 15:03:29.678"},{"co":"0.7","so2":"11","o3":"32","no2":"45","aqi":"63","quality":"良好","pm10":"56","pm2_5":"45","site_name":"宾水西道(启用150702)","o3_8h":"14","primary_pollutant":"PM2.5","ct":"2019-12-13 15:03:29.685"},{"co":"0.7","so2":"11","o3":"34","no2":"53","aqi":"62","quality":"良好","pm10":"62","pm2_5":"44","site_name":"津沽路(启用150702)","o3_8h":"15","primary_pollutant":"PM2.5","ct":"2019-12-13 15:03:29.691"},{"co":"0.7","so2":"12","o3":"35","no2":"58","aqi":"62","quality":"良好","pm10":"63","pm2_5":"44","site_name":"跃进路","o3_8h":"14","primary_pollutant":"PM2.5","ct":"2019-12-13 15:03:29.700"},{"co":"0.5","so2":"5","o3":"40","no2":"29","aqi":"60","quality":"良好","pm10":"69","pm2_5":"42","site_name":"宝白公路","o3_8h":"19","primary_pollutant":"PM10","ct":"2019-12-13 15:03:29.706"},{"co":"1.0","so2":"12","o3":"33","no2":"43","aqi":"58","quality":"良好","pm10":"55","pm2_5":"41","site_name":"大理道(启用160601)","o3_8h":"14","primary_pollutant":"PM2.5","ct":"2019-12-13 15:03:29.711"},{"co":"0.9","so2":"10","o3":"32","no2":"38","aqi":"58","quality":"良好","pm10":"59","pm2_5":"41","site_name":"地纬路","o3_8h":"33","primary_pollutant":"-","ct":"2019-12-13 15:03:29.717"},{"co":"0.5","so2":"11","o3":"35","no2":"37","aqi":"54","quality":"良好","pm10":"58","pm2_5":"34","site_name":"淮河路","o3_8h":"14","primary_pollutant":"PM10","ct":"2019-12-13 15:03:29.724"},{"co":"0.7","so2":"9","o3":"35","no2":"36","aqi":"54","quality":"良好","pm10":"48","pm2_5":"38","site_name":"天和路","o3_8h":"14","primary_pollutant":"-","ct":"2019-12-13 15:03:29.731"},{"co":"0.5","so2":"11","o3":"35","no2":"37","aqi":"54","quality":"良好","pm10":"58","pm2_5":"34","site_name":"淮河道","o3_8h":"14","primary_pollutant":"PM10","ct":"2019-12-13 15:03:29.737"},{"co":"0.6","so2":"6","o3":"38","no2":"36","aqi":"53","quality":"良好","pm10":"54","pm2_5":"37","site_name":"西四道(启用170426)","o3_8h":"14","primary_pollutant":"PM2.5","ct":"2019-12-13 15:03:29.744"},{"co":"0.6","so2":"7","o3":"33","no2":"50","aqi":"52","quality":"良好","pm10":"52","pm2_5":"36","site_name":"大直沽八号路","o3_8h":"15","primary_pollutant":"PM2.5","ct":"2019-12-13 15:03:29.749"},{"co":"0.9","so2":"9","o3":"-","no2":"40","aqi":"52","quality":"良好","pm10":"54","pm2_5":"32","site_name":"辛老路","o3_8h":"4","primary_pollutant":"PM10","ct":"2019-12-13 15:03:29.755"},{"co":"0.7","so2":"6","o3":"31","no2":"36","aqi":"50","quality":"优质","pm10":"50","pm2_5":"29","site_name":"勤俭道","o3_8h":"14","primary_pollutant":"-","ct":"2019-12-13 15:03:29.760"},{"co":"0.7","so2":"6","o3":"31","no2":"36","aqi":"50","quality":"优质","pm10":"50","pm2_5":"29","site_name":"勤俭路","o3_8h":"14","primary_pollutant":"-","ct":"2019-12-13 15:03:29.766"},{"co":"0.9","so2":"7","o3":"38","no2":"43","aqi":"48","quality":"优质","pm10":"44","pm2_5":"33","site_name":"前进道","o3_8h":"17","primary_pollutant":"-","ct":"2019-12-13 15:03:29.771"},{"co":"0.9","so2":"7","o3":"38","no2":"43","aqi":"48","quality":"优质","pm10":"44","pm2_5":"33","site_name":"前进路","o3_8h":"17","primary_pollutant":"-","ct":"2019-12-13 15:03:29.776"},{"co":"0.6","so2":"7","o3":"35","no2":"46","aqi":"47","quality":"优质","pm10":"47","pm2_5":"-","site_name":"中山北路(启用161122)","o3_8h":"16","primary_pollutant":"-","ct":"2019-12-13 15:03:29.781"},{"co":"0.5","so2":"9","o3":"49","no2":"29","aqi":"46","quality":"优质","pm10":"43","pm2_5":"32","site_name":"渔阳路","o3_8h":"21","primary_pollutant":"-","ct":"2019-12-13 15:03:29.788"},{"co":"0.4","so2":"22","o3":"-","no2":"33","aqi":"38","quality":"优质","pm10":"38","pm2_5":"23","site_name":"雍阳西道","o3_8h":"40","primary_pollutant":"-","ct":"2019-12-13 15:03:29.795"},{"co":"0.7","so2":"6","o3":"62","no2":"9","aqi":"20","quality":"优质","pm10":"-","pm2_5":"-","site_name":"东环路","o3_8h":"25","primary_pollutant":"-","ct":"2019-12-13 15:03:29.800"}]}
                }

  • TA的每日心情
    开心
    半小时前
  • 签到天数: 1654 天

    [LV.Master]伴坛终老

    4251

    主题

    6180

    帖子

    11万

    积分

    管理员

    IBC编程社区-原道楠

    Rank: 9Rank: 9Rank: 9

    积分
    113774

    推广达人突出贡献优秀版主荣誉管理论坛元老

    发表于 2020-6-1 09:14:21 | 显示全部楼层
    将json转换成对象   用对象获取
    C#论坛 www.ibcibc.com IBC编程社区
    C#
    C#论坛
    IBC编程社区

    该用户从未签到

    7

    主题

    12

    帖子

    69

    积分

    注册会员

    Rank: 2

    积分
    69
     楼主| 发表于 2020-6-1 11:08:44 | 显示全部楼层
    ibcadmin 发表于 2020-6-1 09:14
    将json转换成对象   用对象获取

    已经解决了,谢谢
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则