0
JSONObject jsonObject;
try {
    int ch;
    StringBuffer b = new StringBuffer();
    System.out.println("Before second while loop");
    while((ch=is.read())!= -1) {
        b.append((char) ch);
    }
    jsonObject = new JSONObject(b.toString());
    String statusStr =  jsonObject.getString("status");
    String responseCode = jsonObject.getString("responseCode");
    Log.e("","JSON STATUS"+statusStr);
    Log.e("","JSON RESPONSE"+responseCode);

I am getting error org.json.JSONException: Value at

jsonObject = new JSONObject(b.toString());
4

1 回答 1

0

Your string in new JSONObject(String) should be in braces. Begin from { and end with }

Also you should have JSON formatted text in your string, like in example

{"person": {"id": "1", "firstName": "first", "lastName": "last", "middleName": "middle"}, "key" : "value" }
于 2012-07-25T09:57:08.553 回答