Skip to content Skip to sidebar Skip to footer

Error Parse Json Response String Android

I have a response String from an API service like this : {'id':'login','status':'true'} and This is the way to parse Response String to get Value from Key 'Status'

Solution 1:

JSONObject jsonObj = null;
try{
    jsonObj = newJSONObject(responseString);
    System.out.println(jsonObj.getString("status"));
}
catch(JSONException e){
    e.printStackTrace();
}

You do not need to bother with any other arrays.

Solution 2:

In which line you get the exception ? In any way may be you should use

jsonObj =JSONObject.fromObject(responseString);

Solution 3:

Kindly try the snippet code below. Try this link for gaining better knowledge about parsing an JSON response.

JSONObject jObj;
        try {
            jObj = newJSONObject(responseString);
            Log.i("id==", jObj.getString("id"));
            Log.i("status==", jObj.getString("status"));
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

Post a Comment for "Error Parse Json Response String Android"