Simplest way to read json from a URL in java

后端 未结 11 1096
情书的邮戳
情书的邮戳 2020-11-22 04:15

This might be a dumb question but what is the simplest way to read and parse JSON from URL in Java?

In Groovy, it\

11条回答
  •  梦如初夏
    2020-11-22 04:58

    I am not sure if this is efficient, but this is one of the possible ways:

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

    construct a JSON object with this string (more at json.org)

    JSONObject(java.lang.String source)
          Construct a JSONObject from a source JSON text string.
    

提交回复
热议问题