Java – how to convert a string to a jsonobject

I'm using httprequest to get JSON from a web to a string

This may be simple, but I can't seem to convert this string to javax json. JsonObject.

What shall I do?

Solution

JsonReader jsonReader = Json.createReader(new StringReader("{}"));
JsonReader jsonReader = Json.createReader(new StringReader("{}"));
JsonObject object = jsonReader.readObject();
jsonReader.close();

See docs and examples for the tricks you should do

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
***
下一篇>>