|
@@ -87,6 +87,22 @@ public class JsonUtil {
|
|
return builder.create().toJson(obj);
|
|
return builder.create().toJson(obj);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 格式化json
|
|
|
|
+ *
|
|
|
|
+ * @author WANGWEI
|
|
|
|
+ * @param json
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public static String format(String json) {
|
|
|
|
+ if (null == json) {
|
|
|
|
+ return json;
|
|
|
|
+ }
|
|
|
|
+ JsonParser jsonParser = new JsonParser();
|
|
|
|
+ JsonElement jsonEl = jsonParser.parse(json);
|
|
|
|
+ return toPrettyJson(jsonEl);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* json转对象
|
|
* json转对象
|
|
*
|
|
*
|