JSONException: Value of type java.lang.String cannot be converted to JSONObject

Reason is some un-wanted characters was added when you compose the String.
The temp solution is

return new JSONObject(json.substring(json.indexOf("{"), json.lastIndexOf("}") + 1));

But try to remove hidden characters on source String.

Leave a Comment