waqas waqas - 3 months ago 10
Android Question

org.json.JSONException: Find specific string from Json Object

I am working in

Android
and finding
json
from internet that looks like this:

JSONObject childObject=me.getJSONObject(pos);
String fisrtkey=childObject.getString("A");
JSONArray jsonArray=childObject.getJSONArray("c");


I want to find
C21
that is in the
A
. See the
json
coming from request.
Can someone help me?

Vij Vij
Answer
try {
        JSONObject j=new JSONObject(data);
        JSONArray c= null;
        c = j.getJSONArray("This");
        JSONObject item=c.getJSONObject(0);
        JSONArray me=item.getJSONArray("me");

        for(int pos=0;pos<me.length();pos++)
        {

            JSONObject childObject=me.getJSONObject(pos);
            String fisrtkey=childObject.getString("A");
            JSONArray jsonArray=childObject.getJSONArray("c");
        }



    } catch (JSONException e1) {
        e1.printStackTrace();
    }

//hope this will help you and also check json is invalid or not ,you missed // bracket of jsonarray "me".

Comments