String JSON = \"http://www.json-generator.com/j/cglqaRcMSW?indent=4\"; JSONObject jsonObject = new JSONObject(JSON); JSONObject getSth = jsonObject.getJSONObject(\"
I had the same, there was an empty new line character at the beginning. That solved it:
int i = result.indexOf("{"); result = result.substring(i); JSONObject json = new JSONObject(result.trim()); System.out.println(json.toString(4));