What is the simplest way to read JSON from a URL in java

0 votes

What is the simplest way to read and parse JSON from URL in Java?

In Groovy, it's a matter of few lines of code. Java examples that I find are ridiculously long (and have huge exception handling block).

I want to read the content of this link

Jun 12, 2018 in Java by scarlett
• 1,280 points
230 views

1 answer to this question.

0 votes

Read json from url use url.openStream() and read contents from a string.

construct a JSON object with this string 

JSONObject(java.lang.String source)
      Construct a JSONObject from a source JSON text string.
answered Jun 13, 2018 by samarth295
• 2,190 points

Related Questions In Java

0 votes
2 answers

What is the easiest way to iterate through the characters of a string in Java?

There are two approaches to this: for(int i ...READ MORE

answered Aug 19 in Java by Sirajul
• 25,700 points
61 views
0 votes
1 answer

What is an efficient way to implement a singleton pattern in Java?

Use an enum: public enum Foo { ...READ MORE

answered Jul 6, 2018 in Java by Akrati
• 3,150 points
86 views
+1 vote
1 answer

What is a simple way to repeat a string in java?

From Java 11 on, there's a method String::repeat that does ...READ MORE

answered Aug 28, 2018 in Java by Frankie
• 9,810 points
408 views
0 votes
1 answer

Which is the standard concise way to copy a file in Java?

As toolkit mentions above, Apache Commons IO ...READ MORE

answered Nov 15, 2018 in Java by Frankie
• 9,810 points
21 views
+1 vote
10 answers

Iterate over a JSONObject?

You can use the following method to ...READ MORE

answered Dec 7, 2018 in Java by Shuvodip
14,338 views
0 votes
1 answer

Using Jackson to deserialise an array of object

First create a mapper : import com.fasterxml.jackson.databind.ObjectMapper;// in ...READ MORE

answered Sep 26, 2018 in Java by Sushmita
• 6,880 points
281 views
0 votes
1 answer

Escaping strings in JSON

You can find a JSON library in your ...READ MORE

answered Oct 3, 2018 in Java by geek.erkami
• 2,320 points
530 views
0 votes
0 answers

Sending request using json object return 404 error code

I am getting mad with this code ...READ MORE

Jun 19 in Java by FooBayo
• 120 points

edited Jun 19 by FooBayo 44 views
+1 vote
3 answers

What is the syntax to declare and initialize an array in java?

You can use this method: String[] strs = ...READ MORE

answered Jul 25, 2018 in Java by samarth295
• 2,190 points
330 views
0 votes
3 answers

How to read a Text File in Java?

You can use readAllLines and the join method to ...READ MORE

answered Jul 27, 2018 in Java by samarth295
• 2,190 points
90 views