使用 Volley API 我将如何解析这个低级别 JSON 以获得这个 url
Using the Volley API how would I parse this low level JSON to get this url
为了简单起见,我删除了很多不重要的内容。我只想要 url 属性。
{
"meta": {
"status": 200,
"msg": "OK"
},
"response": {
"posts": [
{
"photos": [
{
"original_size": {
"url": "LINK",
"width": 612,
"height": 612
String json = "...";
try {
JSONObject jsonObj = new JSONObject(json);
JSONObject respObj = jsonObj.getJSONObject("response");
JSONArray posts = respObj.getJSONArray("posts");
JSONObject firstPost = (JSONObject) posts.get(0);
JSONArray photos = firstPost.getJSONArray("photos");
JSONObject firstPhoto = (JSONObject) photos.get(0);
JSONObject photoSize = firstPhoto.getJSONObject("original_size");
String url = photoSize.getString("url");
Log.e("URL:", url );
} catch (JSONException e) {
e.printStackTrace();
}
为了简单起见,我删除了很多不重要的内容。我只想要 url 属性。
{
"meta": {
"status": 200,
"msg": "OK"
},
"response": {
"posts": [
{
"photos": [
{
"original_size": {
"url": "LINK",
"width": 612,
"height": 612
String json = "...";
try {
JSONObject jsonObj = new JSONObject(json);
JSONObject respObj = jsonObj.getJSONObject("response");
JSONArray posts = respObj.getJSONArray("posts");
JSONObject firstPost = (JSONObject) posts.get(0);
JSONArray photos = firstPost.getJSONArray("photos");
JSONObject firstPhoto = (JSONObject) photos.get(0);
JSONObject photoSize = firstPhoto.getJSONObject("original_size");
String url = photoSize.getString("url");
Log.e("URL:", url );
} catch (JSONException e) {
e.printStackTrace();
}