将gson.JsonObject转换为JSONObject
我有一个gson.JsonObject
对象。 从中创建org.json.JSONObject
对象的最简单方法是什么?
从JsonObject
再次获取JSON字符串并在JSONObject
解析它
JsonObject gson = new JsonParser().parse("{\"id\":\"value\"}").getAsJsonObject(); JSONObject jo2 = new JSONObject(gson.toString());
new org.json.JSONObject(gson.toJson(gson.JsonObject));