如何在android中解析以下JSON数据,并希望在回收器视图中显示它
{"scode":"200","video_limit":"4","app_category":{"cat1":{"app_menu_id":"19","app_menu_name":"Love","video":[{"app_video_id":"1","app_video_name":"video1","app_video_path":"vid1.mp4","app_video_image_path":"vid1.jpg","app_menu_id":"19","app_sub_menu_id":"0","app_menu_name":"Love"},{"app_video_id":"2","app_video_name":"vid2","app_video_path":"vid2.mp4","app_video_image_path":"vid2.jpg","app_menu_id":"19","app_sub_menu_id":"0","app_menu_name":"Love"},{"app_video_id":"4","app_video_name":"vid3","app_video_path":"vid3.mp4","app_video_image_path":"vid3.jpg","app_menu_id":"19","app_sub_menu_id":"0","app_menu_name":"Love"},{"app_video_id":"5","app_video_name":"vid4","app_video_path":"vid4.mp4","app_video_image_path":"vid4.jpg","app_menu_id":"19","app_sub_menu_id":"0","app_menu_name":"Love"}]},"cat2":{"app_menu_id":"21","app_menu_name":"Sad","video":[{"app_video_id":"3","app_video_name":"vid5","app_video_path":"vid5.mp4","app_video_image_path":"vid5.jpg","app_menu_id":"21","app_sub_menu_id":"0","app_menu_name":"Sad"},{"app_video_id":"6","app_video_name":"vid6","app_video_path":"vid6.mp4","app_video_image_path":"vid6.jpg","app_menu_id":"21","app_sub_menu_id":"0","app_menu_name":"Sad"},{"app_video_id":"8","app_video_name":"vid7","app_video_path":"vid7.mp4","app_video_image_path":"vid7.jpg","app_menu_id":"21","app_sub_menu_id":"0","app_menu_name":"Sad"},{"app_video_id":"9","app_video_name":"vid8","app_video_path":"vid8.mp4","app_video_image_path":"vid8.jpg","app_menu_id":"21","app_sub_menu_id":"0","app_menu_name":"Sad"}]}}}
答案 0 :(得分:-1)
使用GsonConverter
https://github.com/square/retrofit/tree/master/retrofit-converters/gson
下面的代码是它的用法。
### https://docs.r4photobiology.info/ggpmisc/articles/user-guide.html
library(ggpmisc)
formula <- y ~ poly(x, 2, raw = TRUE)
p +
stat_smooth(aes(y = Longevity),
method = "lm", formula = formula, se = FALSE, size = 1, color = myColor[2]) +
stat_smooth(aes(y = Infant/scale_ratio + dif),
method = "lm", formula = formula, se = FALSE, size = 1, color = myColor[1]) +
stat_poly_eq(aes(y = Longevity,
label = paste(..eq.label.., ..adj.rr.label..,
sep = "~~italic(\"with\")~~")),
geom = "text", alpha = 0.7,
formula = formula, parse = TRUE,
color = myColor[2],
label.x.npc = 0.5,
label.y.npc = 0.95) +
stat_poly_eq(aes(y = Infant/scale_ratio + dif,
label = paste(..eq.label.., ..adj.rr.label..,
sep = "~~italic(\"with\")~~")),
geom = "text", alpha = 0.7,
color = myColor[1],
formula = formula, parse = TRUE,
label.x.npc = 0.75,
label.y.npc = 0.15) +
NULL