How to conditionally serialize with JAXB or Jackson? External View vs Internal View

后端 未结 2 1722
失恋的感觉
失恋的感觉 2021-01-19 07:05

I\'m building a RESTful API and I have a use case where I need to be able to render two different views of my data. One that we can use internally and one that we will expo

2条回答
  •  无人共我
    2021-01-19 07:17

    I was able to get this working by adding a new library to override the default:

            
            
                com.fasterxml.jackson.core
                jackson-databind
                2.0.6
            
            
                com.fasterxml.jackson.dataformat
                jackson-dataformat-xml
                2.0.5
            
            
                com.fasterxml
                aalto-xml
                0.9.8
            
    

    So now I can serialize to JSON and XML using Jackson and their @JsonView functionality. Very clean! The one I added was aalto-xml.

提交回复
热议问题