Get Jsonarray Key Name
I need to get a key name of JsonArray, so JSON looks like this, please not, that JSON is starting with array brackets, and inside it it has objects, that was made i guess because b
Solution 1:
The JSONArray
contains JSONObject
s. Retrieve every JSONObject
and use keys()
to access the key defined in every JSONObject
JSONArray jArray = new JSONArray(response);
for (int i = 0; i < jArray.length(); i++) {
JSONObject object = jArray.optJSONObject(i);
Iterator<String> iterator = object.keys();
while(iterator.hasNext()) {
String currentKey = iterator.next();
}
}
Post a Comment for "Get Jsonarray Key Name"