A better alternative to Jersey/Jackson for building JSON REST APIs? [closed]
Jersey can serialize POJOs to JSON without any annotations using Jackson. You configure this by setting the JSONConfiguration.FEATURE_POJO_MAPPING
property to true
.
In web.xml
, add the following servlet init parameter:
<init-param> <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name> <param-value>true</param-value></init-param>
I highly recommend JBoss RESTEasy for the REST API. I've used it on a couple of projects and found it to be trivial to setup. It also integrates nicely with Spring if you need that.
I have used both Jackson and Gson for the JSON support with RESTEasy and it is quite simple. All you do is annotate a POJO with JAXB annotations and include the proper libraries.
Another really great part of RESTEasy is the good support for multipart form data. They provide an @MultipartForm annotation which allows you to bind a multipart form to a POJO without writing any code...works slick.
I would advise against Spring MVC for REST because it is not JAX-RS compliant. Using a JAX-RS compliant interface gives you a little bit better portability if you decide to switch to a different implementation down the road.