How to reuse Jersey's JSON/JAXB for serialization?

前端 未结 7 1349
失恋的感觉
失恋的感觉 2020-11-29 23:48

I have a JAX-RS REST service implemented using Jersey. One of the cool features of JAX-RS/Jersey is how easily a POJO can be turned into a REST service, simply by sprinkling

7条回答
  •  半阙折子戏
    2020-11-30 00:41

    Jersey uses a couple different frameworks depending on whether you use mapped(), badgerfish(), or natural() notation. Natural is usually the one people want. And that's implemented using the very good (and very fast) standalone Jackson JSON processor, I believe, which goes from Object->JAXB->JSON. However Jackson also provides it's own JAX-RS provider to go direct Object->JSON.

    In fact, they even added support for JAXB annotations. Have a look at

    http://wiki.fasterxml.com/JacksonJAXBAnnotations

    I think that's ultimately what you are looking for. Jackson does Object<->JSON processing...Jersey just makes the calls for you

提交回复
热议问题