Read embedded object in Jackson

前端 未结 3 1023
一整个雨季
一整个雨季 2020-12-14 08:27

I\'m trying to read a legacy JSON code using Jackson 2.0-RC3, however I\'m stuck with an \"embedded\" object.

Given a following JSON:

{
    \"title\"         


        
3条回答
  •  半阙折子戏
    2020-12-14 09:23

    To deal with an "embedded" object you should use @JsonUnwrapped — it's an equivalent of the Hibernate's @Embeddable/@Embedded.

    class Item {
        private String title;
    
        @JsonProperty("date")
        private Date createdAt;
    
        // How to map this?
        @JsonUnwrapped
        private Author author;
    }
    

提交回复
热议问题