Force Jackson to add addional wrapping using annotations

前端 未结 7 1023
渐次进展
渐次进展 2021-02-12 20:41

I have the following class:

public class Message {
    private String text;

    public String getText() {
        return text;
    }

    public void setText(St         


        
7条回答
  •  北海茫月
    2021-02-12 21:44

    A Simpler/Better way to do it:

    @JsonRootName(value = "message")
    public class Message { ...}
    

    then use
    new ObjectMapper().configure(SerializationFeature.WRAP_ROOT_VALUE, true).writeValueAs...

提交回复
热议问题