Is there any way to get the pretty printing feature in json simple java library.Any example would be good.
Asked
Active
Viewed 1,717 times
2 Answers
0
you just want for developer's perspective then install addons/extensions for your browsers
or if you really want to beautify your code then try

xkeshav
- 53,360
- 44
- 177
- 245
0
For this purpose I am using jackson-mapper-lgpl library. There is DefaultPrettyPrinter that can help you.
Here is my Serializer:
public class JSONSerializer
{
private ObjectMapper mapper;
public JSONSerializer() {
this.mapper = new ObjectMapper();
}
public String serialize(Object ob) throws IOException
{
if (ob == null) {
throw new NullPointerException("Cannot serialize null value");
}
return mapper.defaultPrettyPrintingWriter().writeValueAsString(ob);
}
}

Oleksandr_DJ
- 1,454
- 2
- 14
- 26