NutzCN Logo
问答 json数据格式的网址,怎么解析?
发布于 112天前 作者 wx_jjn2ia9qvotogktb45bf 191 次浏览 复制 上一个帖子 下一个帖子
标签:

json数据格式的网址:http:weather.121.com.cn/data_cache/szWeather/fenquyubao/MESISarea_dp.json?random=0.5436663700307589&_=1545931600738
数据格式:

{"dayreport":{"area":"大鹏区","ddate":"2019-01-28 09:20:00","forecasttime":"2019-01-28 06:00:00","isnextday":0,"h":40,"maxh":85,"mint":15.0,"maxt":20.0,"minrain":0.0,"r":0.0,"state":"多云间阴天,天气干燥","stateen":"Partly cloudy","wd":"东北","ws":"2-3","weatherpic":"02.png","icon":"02"},"hoursweather":[{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-28 07:00:00","isnextday":0,"h":74,"maxh":74,"mint":15.0,"maxt":15.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东北","ws":"2.4","weatherpic":"02_2.png","icon":"02_2"},{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-28 08:00:00","isnextday":0,"h":71,"maxh":71,"mint":16.0,"maxt":16.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东北","ws":"2.4","weatherpic":"02_2.png","icon":"02_2"},{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-28 09:00:00","isnextday":0,"h":67,"maxh":67,"mint":16.0,"maxt":16.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东北","ws":"3.1","weatherpic":"02_2.png","icon":"02_2"},{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-28 10:00:00","isnextday":0,"h":64,"maxh":64,"mint":16.0,"maxt":16.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东北","ws":"3.2","weatherpic":"02_2.png","icon":"02_2"},{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-28 11:00:00","isnextday":0,"h":59,"maxh":59,"mint":17.0,"maxt":17.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东","ws":"2.7","weatherpic":"02_2.png","icon":"02_2"},{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-28 12:00:00","isnextday":0,"h":56,"maxh":56,"mint":18.0,"maxt":18.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东","ws":"3.5","weatherpic":"02_2.png","icon":"02_2"},{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-28 13:00:00","isnextday":0,"h":56,"maxh":56,"mint":19.0,"maxt":19.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东","ws":"3.2","weatherpic":"02_2.png","icon":"02_2"},{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-28 14:00:00","isnextday":0,"h":53,"maxh":53,"mint":20.0,"maxt":20.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东","ws":"3.6","weatherpic":"02_2.png","icon":"02_2"},{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-28 15:00:00","isnextday":0,"h":50,"maxh":50,"mint":20.0,"maxt":20.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东","ws":"3.4","weatherpic":"02_2.png","icon":"02_2"},{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-28 16:00:00","isnextday":0,"h":50,"maxh":50,"mint":20.0,"maxt":20.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东","ws":"3","weatherpic":"02_2.png","icon":"02_2"},{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-28 17:00:00","isnextday":0,"h":45,"maxh":45,"mint":20.0,"maxt":20.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东","ws":"3.1","weatherpic":"02_2.png","icon":"02_2"},{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-28 18:00:00","isnextday":0,"h":50,"maxh":50,"mint":20.0,"maxt":20.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东","ws":"3","weatherpic":"02_2.png","icon":"02_2"},{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-28 19:00:00","isnextday":0,"h":54,"maxh":54,"mint":19.0,"maxt":19.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东南","ws":"2.7","weatherpic":"12_2.png","icon":"12_2"},{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-28 20:00:00","isnextday":0,"h":59,"maxh":59,"mint":18.0,"maxt":18.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东南","ws":"2.5","weatherpic":"12_2.png","icon":"12_2"},{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-28 21:00:00","isnextday":0,"h":58,"maxh":58,"mint":17.0,"maxt":17.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东南","ws":"2.6","weatherpic":"12_2.png","icon":"12_2"},{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-28 22:00:00","isnextday":0,"h":62,"maxh":62,"mint":17.0,"maxt":17.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东南","ws":"3.1","weatherpic":"12_2.png","icon":"12_2"},{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-28 23:00:00","isnextday":0,"h":64,"maxh":64,"mint":16.0,"maxt":16.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东南","ws":"3.2","weatherpic":"12_2.png","icon":"12_2"},{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-29 00:00:00","isnextday":0,"h":68,"maxh":68,"mint":16.0,"maxt":16.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东南","ws":"3.1","weatherpic":"12_2.png","icon":"12_2"},{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-29 01:00:00","isnextday":0,"h":63,"maxh":63,"mint":15.0,"maxt":15.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东南","ws":"3.2","weatherpic":"12_2.png","icon":"12_2"},{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-29 02:00:00","isnextday":0,"h":66,"maxh":66,"mint":15.0,"maxt":15.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东南","ws":"3.3","weatherpic":"12_2.png","icon":"12_2"},{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-29 03:00:00","isnextday":0,"h":65,"maxh":65,"mint":15.0,"maxt":15.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东南","ws":"3","weatherpic":"12_2.png","icon":"12_2"},{"area":"大鹏区","ddate":"2019-01-28 09:20:01","forecasttime":"2019-01-29 04:00:00","isnextday":0,"h":64,"maxh":64,"mint":15.0,"maxt":15.0,"minrain":0.0,"r":0.0,"state":"多云","stateen":"Cloudy","wd":"东南","ws":"3.7","weatherpic":"12_2.png","icon":"12_2"}]}

只需dayreport字段即可,怎么利用nutz在后端解析?

3 回复

依然需要全部解析,Json.fromJson

无Pojo类对应
Json.fromJson(source/*来源参数*/)
有Pojo类对应
Json.fromJson(Class<T> klass, source/*来源参数*/)
Json.fromJson(Type t, source/*来源参数*/)
Pojo集合或Map嵌套
Json.fromJsonAsArray(Class<T> klass, source/*来源参数*/)
Json.fromJsonAsList(Class<T> klass, source/*来源参数*/)
Json.fromJsonAsMap(Class<T> klass, source/*来源参数*/)
从来源看,一般无难度吧

字符串
Json.fromJson(CharSequence c)
Json.fromJson(Class<T> klass, CharSequence c)
Reader
Json.fromJson(Reader c)
Json.fromJson(Class<T> klass, Reader reader)
File
Json.fromJsonFile(Class<T> klass, File f)

这个是文档上的,解析(这个我可以使用)

但是网址要写在哪?

Http.get得到内容后解析

添加回复
请先登陆
回到顶部