List of utility methods to do Json Format
String | formatJson(Object object) format Json ObjectMapper om = new ObjectMapper(); om.enable(SerializationFeature.INDENT_OUTPUT); om.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); return om.writeValueAsString(object); |
String | formatJson(String content) format Json JsonParser parser = new JsonParser(); JsonObject json = parser.parse(content).getAsJsonObject(); Gson gson = new GsonBuilder().setPrettyPrinting().create(); return json == null ? "" : gson.toJson(json); |
String | formatJSON(String jsonData) format JSON Object obj = mapper.readValue(jsonData, Object.class); return toJSON(obj); |