Convert a gson.JsonObject to JSONObject

nik :

I have a gson.JsonObject object. What is the easiest way to create a org.json.JSONObject object from it?

Raman Sahasi :

get JSON string again from JsonObject and parse it in JSONObject

JsonObject gson = new JsonParser().parse("{\"id\":\"value\"}").getAsJsonObject();

JSONObject jo2 = new JSONObject(gson.toString());

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=428917&siteId=1