Skip to content Skip to sidebar Skip to footer

Parse JSON Android Convert JsonObject

I have a problem with JSON I get a json since https://proxyepn-test.epnbn.net/wsapi/epn But when I want to display a single data eg 'name'. The console displays: Log org.json.JSONE

Solution 1:

Try below:

JSONObject obj = new JSONObject(test2);
JSONObject data = obj.getJSONObject("data");
Iterator<String> iterator = data.keys();
while(iterator.hasNext()){
        String key = iterator.next();
        String Name = data.getString(key);
}

Solution 2:

JSONObject obj = new JSONObject(test2);
JSONObject data=obj.getJSONobject("data");
JSONObject ob1=obj.getJSONobject("1");
String pageName = ob1.getString("Name");

Solution 3:

You have to parse your next level of JSONObject (labeled as "1","2","3".. from response).

It seems like issue in Json response structure you shared. why cann't it be array inside "data"?

Then you can easily read data as JSONArray with those objects as ("1","2","3"..) array item.

Else

Android JSON parsing of multiple JSONObjects inside JSONObject


Post a Comment for "Parse JSON Android Convert JsonObject"