1

Is there any way to get the pretty printing feature in json simple java library.Any example would be good.

Ramesh
  • 2,217
  • 5
  • 33
  • 62
  • [try this](http://stackoverflow.com/questions/352098/how-to-pretty-print-json-script) – kev Jan 03 '12 at 10:01

2 Answers2

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

http://jsbeautifier.org/

diEcho
  • 52,196
  • 40
  • 166
  • 239
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,374
  • 2
  • 13
  • 26