hstaudacher / osgi-jax-rs-connector

An OSGi - JAX-RS 2.0 Connector, software repository available on the link below
http://hstaudacher.github.io/osgi-jax-rs-connector
Other
190 stars 98 forks source link

Make it easier to configure how GSON serialization/deserialization is done #138

Closed tomsontom closed 8 years ago

tomsontom commented 8 years ago

My current use case is that I want to control how GSON serializes Date-Objects (I want them to be converted to an ISO-DateTime yyyy-MM-ddTHH:mm:ssZ).

I would propose that one can contribute an OSGi-Service who is responsible to create the Gson-Instance - if you'd accept such a contribution I would contribute such an API

hstaudacher commented 8 years ago

Hey Tom, actually such an API already exist, see com.eclipsesource.jaxrs.provider.gson.GsonProvider.setGson(Gson)

You can request an instance of GsonProvider and set the Gson that is used. It's not the nicest API but it should cover your usecase.

Also another alternative is that you just register your own @Provider. The gson provide delivered is just for convenience.