How to parse a JSON Input stream

前端 未结 11 1933
野的像风
野的像风 2020-11-30 01:06

I am using java to call a url that returns a JSON object:

url = new URL(\"my URl\");
urlInputStream = url.openConnection().getInputStream();
<
11条回答
  •  甜味超标
    2020-11-30 01:51

    I suggest use javax.json.Json factory as less verbose possible solution:

    JsonObject json = Json.createReader(yourInputStream).readObject();
    

    Enjoy!

提交回复
热议问题