2012-01-03 70 views

回答

0

你只是想为开发人员的角度,然后安装插件/扩展您的浏览器

,或者如果你真的想美化你的代码,然后尝试

http://jsbeautifier.org/

0

为此我使用jackson-mapper-lgpl图书馆。 有DefaultPrettyPrinter,可以帮助你。

这里是我的串行:

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); 
} 
}