sinat_24423367 2015-08-17 03:51 采纳率: 83.3%
浏览 1780
已采纳

这个json数据如何用gson解析?

{
errNum: 0,
errMsg: "success",
retData: {
city: "北京",
cityid: "101010100",
today: {
date: "2015-08-03",
week: "星期一",
curTemp: "28℃",
aqi: "92",
fengxiang: "无持续风向",
fengli: "微风级",
hightemp: "30℃",
lowtemp: "23℃",
type: "阵雨",
index: [
{
name: "感冒指数",
code: "gm",
index: "",
details: "各项气象条件适宜,发生感冒机率较低。但请避免长期处于空调房间中,以防感冒。",
otherName: ""
},
{
code: "fs",
details: "属中等强度紫外辐射天气,外出时应注意防护,建议涂擦SPF指数高于15,PA+的防晒护肤品。",
index: "中等",
name: "防晒指数",
otherName: ""
},
{
code: "ct",
details: "天气炎热,建议着短衫、短裙、短裤、薄型T恤衫等清凉夏季服装。",
index: "炎热",
name: "穿衣指数",
otherName: ""
},
{
code: "yd",
details: "有降水,推荐您在室内进行低强度运动;若坚持户外运动,须注意选择避雨防滑并携带雨具。",
index: "较不宜",
name: "运动指数",
otherName: ""
},
{
code: "xc",
details: "不宜洗车,未来24小时内有雨,如果在此期间洗车,雨水和路上的泥水可能会再次弄脏您的爱车。",
index: "不宜",
name: "洗车指数",
otherName: ""
},
{
code: "ls",
details: "有降水,不适宜晾晒。若需要晾晒,请在室内准备出充足的空间。",
index: "不宜",
name: "晾晒指数",
otherName: ""
}
]
},
forecast: [
{
date: "2015-08-04",
week: "星期二",
fengxiang: "无持续风向",
fengli: "微风级",
hightemp: "32℃",
lowtemp: "23℃",
type: "多云"
},
{
date: "2015-08-05",
week: "星期三",
fengxiang: "无持续风向",
fengli: "微风级",
hightemp: "30℃",
lowtemp: "23℃",
type: "多云"
},
{
date: "2015-08-06",
week: "星期四",
fengxiang: "无持续风向",
fengli: "微风级",
hightemp: "29℃",
lowtemp: "24℃",
type: "雷阵雨"
},
{
date: "2015-08-07",
week: "星期五",
fengxiang: "无持续风向",
fengli: "微风级",
hightemp: "30℃",
lowtemp: "24℃",
type: "多云"
}
],
history: [

        {
            date: "2015-07-31",
            week: "星期五",
            aqi: "52",
            fengxiang: "无持续风向",
            fengli: "微风级",
            hightemp: "高温 29℃",
            lowtemp: "低温 22℃",
            type: "多云"
        },
        {
            date: "2015-08-01",
            week: "星期六",
            aqi: null,
            fengxiang: "南风",
            fengli: "微风级",
            hightemp: "高温 35℃",
            lowtemp: "低温 26℃",
            type: "多云"
        }
    ]
}

}

  • 写回答

8条回答 默认 最新

  • JPF1024 2015-08-17 06:32
    关注
     public class WeatherRetData {
    private String city;
    private String cityid;
    private List<WeatherResult> today;//这样.-----------------------------
    private List<Forecast > forecast; //这样--------------------------------
    private List<History> history;//
    ......get/set......
    }
    

    参考这个方式改一下,然后在试试

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(7条)

报告相同问题?

悬赏问题

  • ¥15 k8s集群重启后,kubelet一直报systemctl restart kubelet.service "Failed to delete cgroup paths"
  • ¥15 微信小程序构建工具类发布到npm,install后报错
  • ¥15 amesim液压仿真问题
  • ¥15 python解析json文件时报错
  • ¥15 MATLAB优化设计
  • ¥15 ANN预测模型 200大米
  • ¥20 优秀学生的问题 oj java
  • ¥15 scratch-gui 如何集成进 react native
  • ¥15 把全局悬浮窗改为局内悬浮窗
  • ¥15 Excel vba编程调用word如何读取换行符