使用JsonObject生成的json,格式不好看,少了换行和缩进
//组装成需要的json ???????????JSONObject finalJson = new JSONObject();
?........ ???????????//美化 ???????????ObjectMapper mapper = new ObjectMapper(); ???????????Object obj = mapper.readValue(finalJson.toString(), Object.class); ???????????String beautify = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(obj); ???????????logger.debug("美化后:{}",beautify);
json美化格式
原文地址:https://www.cnblogs.com/chn58/p/8514595.html