My JSONObject:
{MyJSON:[{"id":"1","name":"panji","price":"100"}]}
I do this to get value of id:
menuitemArray.getJSONObject(i).getString("id");
Can I get the value of id, name or price, without mentioning its name, may be like index or another method?
Best Answer
You can call
names()
on aJSONObject
to get aJSONArray
of the names of its elements - this would let you do logic on them or retrieve their corresponding values dynamically.