Wie bekomme ich diesen JSON-Schlüssel und -Wert aus dem Web. Das ist mein Code, aber ich kann das nicht von der zweiten Iteration bekommen. kann mir jemand dabei helfen?Wie bekomme ich Json Schlüssel und Wert mit Iterator in andorid
Json Antwort:
"attributes": [
{
"main_id": "3",
"Color": [
{
"id": "60",
"text": "46(+$0.00)"
}
]
},
{
"main_id": "21",
"dede": [
{
"id": "73",
"text": "baba(+$0.00)"
}
]
}
]
Das ist mein Android-Code, um die Werte zu analysieren:
JSONArray jsonArrayAttributes = jsonObj.getJSONArray("attributes");
for (int i = 0; i < jsonArrayAttributes.length(); i++) {
JSONObject jsonObject1 = jsonArrayAttributes.getJSONObject(i);
Iterator iteratorKey = jsonObject1.keys();
String strAttrId = (String) iteratorKey.next();
String strAttrName = (String) iteratorKey.next();
JSONArray jsonArrayName = jsonObject1.getJSONArray(strAttrName);
for (int j = 0; j < jsonArrayName.length(); j++) {
JSONObject jsonObjName = jsonArrayName.getJSONObject(j);
}
}
Ich kann diese JSON-Antwort nicht erreichen. Ich habe die Antwort entsprechend geändert. – syedjibharat