使用JsonObject生成的json,格式很差看,少了换行和缩进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);