Class JsonGsonFeature

java.lang.Object
org.glassfish.jersey.gson.JsonGsonFeature
All Implemented Interfaces:
Feature

public class JsonGsonFeature extends Object implements Feature
Feature used to register Gson providers.

The Feature is automatically enabled when JsonGsonAutoDiscoverable is on classpath. Default GSON configuration obtained by calling GsonBuilder.create() is used.

Custom configuration, if required, can be achieved by implementing custom ContextResolver and registering it as a provider into JAX-RS runtime:

 @Provider
 @class GsonContextResolver implements ContextResolver<Gson> {
      @Override
      public Gson getContext(Class<?> type) {
          GsonBuilder builder = new GsonBuilder();
          // add custom configuration
          return builder.create();
      }
 }
 
  • Constructor Details

    • JsonGsonFeature

      public JsonGsonFeature()
  • Method Details