2

Searching up on google I found this solution to read json strings from URL:

JSONObject json = new JSONObject(IOUtils.toString(new URL("https://somelink.com"), Charset.forName("UTF-8")));

The problem is that there is no JSONObject(String) constructor, why is that?

1 Answer 1

5

I thin you use google-gson, use org.json, there is constructor:

JSONObject obj = new JSONObject(str);
String myData = obj.getString("myData");
Sign up to request clarification or add additional context in comments.

1 Comment

do you use org.json ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.