java怎么解析[开头的json
怎么用java解析[{"Title":"济南天气预报","Description":"","PicUrl":"","Url":""},{"Title":"周一(今天,实时...
怎么用java解析
[{"Title":"济南天气预报","Description":"","PicUrl":"","Url":""},{"Title":"周一(今天, 实时:21℃)\n阴转多云 南风微风 22 ~ 14℃","Description":"","PicUrl":"http://api.map.baidu.com/images/weather/day/yin.png","Url":""},{"Title":"周二\n晴 南风3-4级 24 ~ 14℃","Description":"","PicUrl":"http://api.map.baidu.com/images/weather/day/qing.png","Url":""},{"Title":"周三\n晴转阴 南风3-4级 24 ~ 11℃","Description":"","PicUrl":"http://api.map.baidu.com/images/weather/day/qing.png","Url":""},{"Title":"周四\n多云转晴 北风3-4级 19 ~ 7℃","Description":"","PicUrl":"http://api.map.baidu.com/images/weather/day/duoyun.png","Url":""}] 展开
[{"Title":"济南天气预报","Description":"","PicUrl":"","Url":""},{"Title":"周一(今天, 实时:21℃)\n阴转多云 南风微风 22 ~ 14℃","Description":"","PicUrl":"http://api.map.baidu.com/images/weather/day/yin.png","Url":""},{"Title":"周二\n晴 南风3-4级 24 ~ 14℃","Description":"","PicUrl":"http://api.map.baidu.com/images/weather/day/qing.png","Url":""},{"Title":"周三\n晴转阴 南风3-4级 24 ~ 11℃","Description":"","PicUrl":"http://api.map.baidu.com/images/weather/day/qing.png","Url":""},{"Title":"周四\n多云转晴 北风3-4级 19 ~ 7℃","Description":"","PicUrl":"http://api.map.baidu.com/images/weather/day/duoyun.png","Url":""}] 展开
3个回答
展开全部
一个{}当成一个对象,一个{}里面的“”:“”当成一个属性的key-value对。然后在java中这样写:
java中用jsonStr接收json类型的对象字符串
Gson gson = new Gson();
List<Map<Strring,String>> JsonList = gson.fromJson(jsonStr,Object.class);
这里一个Map就相当于[]中的一个{};
然后你循环遍历List,和从Map中取值就可以了!
java中用jsonStr接收json类型的对象字符串
Gson gson = new Gson();
List<Map<Strring,String>> JsonList = gson.fromJson(jsonStr,Object.class);
这里一个Map就相当于[]中的一个{};
然后你循环遍历List,和从Map中取值就可以了!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询