Jax-rs json pretty output

前端 未结 6 1615
执笔经年
执笔经年 2020-12-08 22:48

in Java when i use the

@Produces(\"application/json\")

annotation the output is not formated into human readable form. How do i achive that

6条回答
  •  不思量自难忘°
    2020-12-08 23:21

    Just for the record, if you want to enable the pretty output only for some resources you can use the @JacksonFeatures annotation on a resource method.

    Here is example:

    @Produces(MediaType.APPLICATION_JSON)
    @JacksonFeatures(serializationEnable =  { SerializationFeature.INDENT_OUTPUT })
    public Bean resource() {
        return new Bean();
    }
    

提交回复
热议问题