-2
JSON对象,我有这个代码试图从JSON对象中提取电子邮件如何检索机器人
JSONArray one = reader.getJSONArray("taxis");
for (i = 0; i < one.length(); i++) {
two = one.getJSONObject(i);
distance = two.getString("taxis");
three = two.getJSONArray("taxis");
for (j = 0; j < three.length(); j++) {
four = three.getJSONObject(j);
distance = four.getString("email");
}
}
我得到JSON结果这样
{
"taxis": [
{
"taxis": {
"id": "1",
"email": "[email protected]",
"password": "0cc175b9c0f1b6a831c399e269772661",
"name": "Thamaraiselvam"
}
},
{
"taxis": {
"id": "3",
"email": "[email protected]",
"password": "3bf575512fdce89fd4e3ba87a230b2f4",
"name": "Arunesh"
}
},
{
"taxis": {
"id": "4",
"email": "[email protected]",
"password": "0cc175b9c0f1b6a831c399e269772661",
"name": "A"
}
}
]
}
如何提取电子邮件,使用Android的密码和名称? 我没有得到任何东西,当我上面的几个JSON解析库代码
有什么用处? – 2015-02-07 14:40:37
请再次看到我的问题花花公子 – Thamaraiselvam 2015-02-07 14:48:07
变量的命名可以改进,以减少混淆。另外你的JSON结构中只有一个数组... – Henry 2015-02-07 14:56:07