zoukankan      html  css  js  c++  java
  • JAVA之带转义字符的json字符串解析

    Json数据:

     
    1. {  
    2.     "ret": "0",  
    3.     "Weathers": "[{"date":"2017-03-20","weatherType":"阴,大部分地区有零星小雨或小雨,上午能见度2-5km转阴天间多云","temperature_min":"6","wind_force":"微风","temperature_max":"12","wind_direction":""},{"date":"2017-03-21","weatherType":"阴转多云","temperature_min":"6","wind_force":"微风","temperature_max":"13","wind_direction":""},{"date":"2017-03-22","weatherType":"多云转阴","temperature_min":"6","wind_force":"微风","temperature_max":"14","wind_direction":""},{"date":"2017-03-23","weatherType":"阴转小雨","temperature_min":"3","wind_force":"微风","temperature_max":"10","wind_direction":""},{"date":"2017-03-24","weatherType":"雨夹雪转多云","temperature_min":"0","wind_force":"微风","temperature_max":"5","wind_direction":""},{"date":"2017-03-25","weatherType":"多云转晴","temperature_min":"5","wind_force":"微风转3到4级","temperature_max":"13","wind_direction":""},{"date":"2017-03-26","weatherType":"晴","temperature_min":"4","wind_force":"3到4级","temperature_max":"14","wind_direction":""}]"  
    4. }  
     
      1. JSONObject jsonObject = new JSONObject(result);  
      2. String weathers = jsonObject.getString("Weathers");  
      3. JSONArray weathersArray = new JSONArray(weathers);  
      4. //直接这样解析会报错  
      5. //JSONArray weathersArray = jsonObject.getJSONArray("weathers");  

    转载于:http://blog.csdn.net/panyzyw/article/details/64130020

  • 相关阅读:
    函数对象与闭包
    20.03.19作业
    关键字参数,名称空间和作用域
    作业03.18
    函数第二天
    20.03.17作业
    文件
    20.01.16作业
    前端基础
    前端知识(二)
  • 原文地址:https://www.cnblogs.com/mr-wuxiansheng/p/8166443.html
Copyright © 2011-2022 走看看