From 8b7a0d4147000f93b53d1b615b11710e7c99a6b9 Mon Sep 17 00:00:00 2001 From: lynn Date: Tue, 15 Dec 2020 15:31:31 +0800 Subject: [PATCH] disableHtmlEscaping --- src/main/java/hi/chyl/json/MainView.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main/java/hi/chyl/json/MainView.java b/src/main/java/hi/chyl/json/MainView.java index 550f2a6..af689e2 100644 --- a/src/main/java/hi/chyl/json/MainView.java +++ b/src/main/java/hi/chyl/json/MainView.java @@ -666,10 +666,7 @@ private void formatJson() { text = JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue); jsonEle = JsonParser.parseString(text); if (jsonEle != null && !jsonEle.isJsonNull()) { - GsonBuilder gb = new GsonBuilder(); - gb.setPrettyPrinting(); - gb.serializeNulls(); - Gson gson = gb.create(); + Gson gson = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().serializeNulls().create(); String jsonStr = gson.toJson(jsonEle); if (jsonStr != null) { // jsonStr = StringEscapeUtils.unescapeJava(jsonStr); @@ -710,10 +707,7 @@ private void sortFormatJson() { text = JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue, SerializerFeature.MapSortField); jsonEle = JsonParser.parseString(text); if (jsonEle != null && !jsonEle.isJsonNull()) { - GsonBuilder gb = new GsonBuilder(); - gb.setPrettyPrinting(); - gb.serializeNulls(); - Gson gson = gb.create(); + Gson gson = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().serializeNulls().create(); String jsonStr = gson.toJson(jsonEle); if (jsonStr != null) { // jsonStr = StringEscapeUtils.unescapeJava(jsonStr);