我有一个小的功能,使一个JSON API请求,并返回一个字符串Postexecute:JSON有多个同名的对象
public class fetch extends AsyncTask<URL, Void, String> {
@Override
protected String doInBackground(URL... urls) {
URL search = urls[0];
String results = null;
try {
results = getResponse(search);
} catch (IOException e) {
e.printStackTrace();
}
return results;
}
现在我希望得到一些具体的JSON对象,但我有多个同一物品:
[
{
"A1": {
"about": {
"IDs": [19]
}, ,
"value": 1
},
"A2": {
"about": {
"IDs": [19]
},
"value": 2
}
},
{
"A1": {
"about": {
"IDs": [20]
}, ,
"value": 3
},
"A2": {
"about": {
"IDs": [20]
},
"value": 4
}
}
]
我该怎么做?
'[...]'代表阵列。如果您知道数组中的哪个项目,那么只需使用该项目的索引,可能通过像'yourJsonArray.get(index)'这样的东西。 – Pshemo