Force Jackson to add addional wrapping using annotations

前端 未结 7 976
渐次进展
渐次进展 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:39

    I have created a small jackson module that contains a @JsonWrapped annotation, that solves the problem. See here for the code: https://github.com/mwerlitz/jackson-wrapped

    Your class would then look like:

    public class Message {
        @JsonWrapped("message")
        private String text;
    }
    

提交回复
热议问题