Class JacksonFeature

java.lang.Object
org.glassfish.jersey.jackson.JacksonFeature
All Implemented Interfaces:
Feature

public class JacksonFeature extends Object implements Feature
Feature used to register Jackson JSON providers.
Author:
Stepan Kopriva, Michal Gajdos
  • Constructor Details

    • JacksonFeature

      public JacksonFeature()
      Default constructor enables registering Jackson's exception mappers
  • Method Details

    • withExceptionMappers

      public static JacksonFeature withExceptionMappers()
      Create JacksonFeature with working Jackson's exception mappers
      Returns:
      JacksonFeature with working Jackson's exception mappers
    • withoutExceptionMappers

      public static JacksonFeature withoutExceptionMappers()
      Create JacksonFeature without registered Jackson's exception mappers
      Returns:
      JacksonFeature without registered Jackson's exception mappers
    • maxStringLength

      public JacksonFeature maxStringLength(int maxStringLength)

      Sets the MessageProperties.JSON_MAX_STRING_LENGTH property to a provided value. The property value already configured takes priority.

      Both uses of maxStringLength(int) and MessageProperties.JSON_MAX_STRING_LENGTH override StreamReadConstraints defined on Jackson's ObjectMapper's JsonFactory provided via ContextResolver<ObjectMapper>.

      Parameters:
      maxStringLength - the integer value to override the default Jackson's StreamReadConstraints.DEFAULT_MAX_STRING_LEN.
      Returns:
      JacksonFeature that has the Jackson's StreamReadConstraints.DEFAULT_MAX_STRING_LEN set.
    • configure

      public boolean configure(FeatureContext context)
      Specified by:
      configure in interface Feature