JSON解析Android Java [英] JSON Parsing Android Java

查看:124
本文介绍了JSON解析Android Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想解析这个json但我无法做到.继承人的Json结构:

i would like to parse this json but im not able to do it. Heres the Json Structure:

例如:我想获取String产品类型=> Car

For example: I would like to get String product type => Car

此代码无效:

JSONObject mainData = response.getJSONObject("decode");
String productType = mainData.getString("Product Type");

请帮助

推荐答案

decode是不是对象的数组,因此应该是

decode is an array not an object so it should be

JSONArray mainData = response.getJSONArray("decode");

然后您可以使用索引获取内部对象.

And then you can get inside objects using the index.

JSONObject jsonObj = mainData.getJSONObject(0);
String answer = jsonObj.getString("label"); //Make

这篇关于JSON解析Android Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆