Jackson JSON Deserialization: array elements in each line

后端 未结 6 1929
野趣味
野趣味 2020-12-15 06:28

I am using Jackson and would like to pretty-print JSON such that each element in arrays goes to each line, like:

{
  \"foo\" : \"bar\",
  \"blah\" : [
    1,
             


        
6条回答
  •  眼角桃花
    2020-12-15 06:50

    Mapper can be configured (jackson-2.6) with:

    ObjectMapper mapper = ...
    DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter();
    prettyPrinter.indentArraysWith(DefaultIndenter.SYSTEM_LINEFEED_INSTANCE);
    mapper.setDefaultPrettyPrinter(prettyPrinter);
    
    //use mapper 
    

提交回复
热议问题