为了账号安全,请及时绑定邮箱和手机立即绑定

如何用 Java 读取这个 JSON?

如何用 Java 读取这个 JSON?

凤凰求蛊 2022-01-12 16:34:55
我有这段JSON代码,但我不知道如何阅读poster_path。我知道有很多教程,但没有一个对我有用,如果有人帮助我,那就太好了。{     "movie_results":[        {           "adult":false,         "backdrop_path":"/j9XKiZrVeViAixVRzCta7h1VU9W.jpg",         "genre_ids":[              80,            18         ],         "id":278,         "original_language":"en",         "original_title":"The Shawshank Redemption",         "overview":"Framed in the 1940s for the double murder of his wife and her lover, upstanding banker Andy Dufresne begins a new life at the Shawshank prison, where he puts his accounting skills to work for an amoral warden. During his long stretch in prison, Dufresne comes to be admired by the other inmates -- including an older prisoner named Red -- for his integrity and unquenchable sense of hope.",         "poster_path":"/9O7gLzmreU0nGkIB6K3BsJbzvNv.jpg",         "release_date":"1994-09-23",         "title":"The Shawshank Redemption",         "video":false,         "vote_average":8.6,         "vote_count":11374,         "popularity":30.881      }   ],   "person_results":[     ],   "tv_results":[     ],   "tv_episode_results":[     ],   "tv_season_results":[     ]}
查看完整描述

1 回答

?
一只斗牛犬

TA贡献1784条经验 获得超2个赞

使用 JSONObject:


JSONOBject json = new JSONObject(string);

String posterPath = json.getJSONArray("movie_results")

                    .getJSONObject(index)

                    .getString("poster_path");


查看完整回答
反对 回复 2022-01-12
  • 1 回答
  • 0 关注
  • 158 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信