How to convert String to JsonObject

后端 未结 2 741
清酒与你
清酒与你 2021-01-01 09:20

I am using a httprequest to get Json from a web into a string.

It is probably quite simple, but I cannot seem to convert this string to a javax.js

2条回答
  •  抹茶落季
    2021-01-01 10:02

    Since the above reviewer didn't like my edits, here is something you can copy and paste into your own code:

    private static JsonObject jsonFromString(String jsonObjectStr) {
    
        JsonReader jsonReader = Json.createReader(new StringReader(jsonObjectStr));
        JsonObject object = jsonReader.readObject();
        jsonReader.close();
    
        return object;
    }
    

提交回复
热议问题