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

后端 未结 2 1779
失恋的感觉
失恋的感觉 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:40

    Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group.

    EclipseLink JAXB (MOXy) offers an external mapping file. This mapping file can augment or completely replace the metadata supplied via annotations. Below is an example where the same object model is mapped to two different weather services (Google and Yahoo)

    • http://blog.bdoughan.com/2011/09/mapping-objects-to-multiple-xml-schemas.html

    MOXy also supports both XML and JSON binding:

    • http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html

    MOXy also integrates easily with JAX-RS implementations:

    • http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html

提交回复
热议问题