How to output formated JSON from a JSONObject

JSONObject jo = new JSONObject();
.....
ObjectMapper mapper = new ObjectMapper();
Object json = mapper.readValue(jo.toString(), Object.class);
System.out.println("var data = " + mapper.writerWithDefaultPrettyPrinter().writeValueAsString(json) + ";");

No comments:

Post a Comment