2012-01-03 67 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); 
} 
}