标签:单引号 json one net tin The article 解决 log
//Creating the JSON object, and getting as String:
JsonObject json = new JsonObject();
JsonObject inner = new JsonObject();
inner.addProperty("value", "xpath(‘hello‘)");
json.add("root", inner);
System.out.println(json.toString());
//Trying to pretify JSON String:
Gson gson = new GsonBuilder().setPrettyPrinting().create();
JsonParser parser = new JsonParser();
JsonElement je = parser.parse(json.toString());
System.out.println(gson.toJson(je));
输出
{"root":{"value":"xpath(‘hello‘)"}}
{
"root": {
"value": "xpath(\u0027hello\u0027)"
}
}
解决办法
Gson gs = new GsonBuilder()
.setPrettyPrinting()
.disableHtmlEscaping()
.create();
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow
标签:单引号 json one net tin The article 解决 log
原文地址:https://www.cnblogs.com/skinchqqhah/p/10351467.html