Genson and Jersey overview
Jersey is a great library for developing RESTful web services. It is possible to use many different media types for representing data; if some media type is missing, additional libraries can be registered.
Genson is a JSON <-> Java library, very fast with small footprint.
It is possible to use Genson within Jersey as a JSON serializer/deserializer. Registration of GENSON library with Jersey is different depending on the Jersey version:
Jersey 2.9 and below:
It is enough to have Genson in classpath, Jersey will atomatically find it and use. No special configuration is needed.
Jersey 2.10 and above:
Automatic registration is disabled in newer version of the libraries (I have no idea why). It is required to register Jersey using Register method of the ResourceConfig class. Below is two step example how to do it:
- Create class that extends ResourceConfig
- Set new class as Application parameter in web.xml configuration file: