Tuesday, December 4, 2012

Jackson Pretty Print

Some of the solutions posted online is deprecated.

Here's the way to do it with a recent version of Jackson.


ObjectWriter jsonWriter = (new ObjectMapper()).writerWithDefaultPrettyPrinter();
String result = jsonWriter.writeValueAsString(obj);

No comments:

Post a Comment