I'm trying to read json by url. This is my effort:
public String getContentByUrl(String url) throws IOException, JSONException {
JSONObject json = new JSONObject(IOUtils.toString(new URL(url), Charset.forName("UTF-8")));
return json.toString();
}
Throws
A JSONObject text must begin with '{' at 2 [character 3 line 1]
Also I tried JSONPObject
, but it hasn't got such constructor. What do?