Got stuck at this error:
3169-3190/com.meisolsson.app E/JSON Parser﹕ Error parsing data org.json.JSONException: Value [{\"type\":0,\"can_see_custom_stori
[..]
means it should be an JSONArray
and {..}
means it should be a JSONObject
.
Therefore:
try {
JSONArray jObj = new JSONArray(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
Even though I had a single JSON object it was stored in an array as Hariharan has pointed out with the square brackets [ { items:items, ... } ]
My solution was simply to parse out the only object, located in array position [0] like this
JSONArray jsonArray = new JSONArray(stringIn);
JSONObject obj = jsonArray.getJSONObject(0);