Class JacksonConfiguration

  • All Implemented Interfaces:
    io.micronaut.json.JsonConfiguration

    @ConfigurationProperties("jackson")
    public class JacksonConfiguration
    extends java.lang.Object
    implements io.micronaut.json.JsonConfiguration
    Configuration for the Jackson JSON parser.
    Since:
    1.0
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> com.fasterxml.jackson.databind.JavaType constructType​(io.micronaut.core.type.Argument<T> type, com.fasterxml.jackson.databind.type.TypeFactory typeFactory)
      Constructors a JavaType for the given argument and type factory.
      int getArraySizeThreshold()  
      java.lang.String getDateFormat()  
      com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping getDefaultTyping()  
      java.util.Map<com.fasterxml.jackson.databind.DeserializationFeature,​java.lang.Boolean> getDeserializationSettings()  
      java.util.Map<com.fasterxml.jackson.core.JsonFactory.Feature,​java.lang.Boolean> getFactorySettings()  
      java.util.Map<com.fasterxml.jackson.core.JsonGenerator.Feature,​java.lang.Boolean> getGeneratorSettings()  
      java.util.Locale getLocale()  
      java.util.Map<com.fasterxml.jackson.databind.MapperFeature,​java.lang.Boolean> getMapperSettings()  
      java.util.Map<com.fasterxml.jackson.core.JsonParser.Feature,​java.lang.Boolean> getParserSettings()  
      com.fasterxml.jackson.databind.PropertyNamingStrategy getPropertyNamingStrategy()  
      com.fasterxml.jackson.annotation.JsonInclude.Include getSerializationInclusion()  
      java.util.Map<com.fasterxml.jackson.databind.SerializationFeature,​java.lang.Boolean> getSerializationSettings()  
      java.util.TimeZone getTimeZone()  
      boolean isAlwaysSerializeErrorsAsList()
      Whether _embedded.errors should always be serialized as list.
      boolean isBeanIntrospectionModule()
      Whether the BeanIntrospection should be used for reflection free object serialialization/deserialialization.
      boolean isModuleScan()
      Whether Jackson modules should be scanned for.
      boolean isTrimStrings()
      Whether strings should be trimmed when deserializing.
      void setAlwaysSerializeErrorsAsList​(boolean alwaysSerializeErrorsAsList)
      Sets whether _embedded.errors should always be serialized as list (defaults to false).
      void setArraySizeThreshold​(int arraySizeThreshold)
      Sets the array size threshold for data binding.
      void setBeanIntrospectionModule​(boolean beanIntrospectionModule)
      Whether the BeanIntrospection should be used for reflection free object serialialization/deserialialization.
      void setDateFormat​(java.lang.String dateFormat)
      Sets the default date format to use.
      void setDefaultTyping​(com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping defaultTyping)
      Sets the global defaultTyping using for Polymorphic handling.
      void setDeserialization​(java.util.Map<com.fasterxml.jackson.databind.DeserializationFeature,​java.lang.Boolean> deserialization)
      Sets the deserialization features to use.
      void setFactory​(java.util.Map<com.fasterxml.jackson.core.JsonFactory.Feature,​java.lang.Boolean> factory)
      Sets the factory features to use.
      void setGenerator​(java.util.Map<com.fasterxml.jackson.core.JsonGenerator.Feature,​java.lang.Boolean> generator)
      Sets the generator features to use.
      void setLocale​(java.util.Locale locale)
      Sets the locale to use.
      void setMapper​(java.util.Map<com.fasterxml.jackson.databind.MapperFeature,​java.lang.Boolean> mapper)
      Sets the object mapper features to use.
      void setModuleScan​(boolean moduleScan)
      Sets whether to scan for modules or not (defaults to true).
      void setParser​(java.util.Map<com.fasterxml.jackson.core.JsonParser.Feature,​java.lang.Boolean> parser)
      Sets the parser features to use.
      void setPropertyNamingStrategy​(com.fasterxml.jackson.databind.PropertyNamingStrategy propertyNamingStrategy)
      Sets the property naming strategy.
      void setSerialization​(java.util.Map<com.fasterxml.jackson.databind.SerializationFeature,​java.lang.Boolean> serialization)
      Sets the serialization features to use.
      void setSerializationInclusion​(com.fasterxml.jackson.annotation.JsonInclude.Include serializationInclusion)
      Sets the serialization inclusion mode.
      void setTimeZone​(java.util.TimeZone timeZone)
      Sets the timezone to use.
      void setTrimStrings​(boolean trimStrings)
      Whether strings should be trimmed when deserializing (defaults to false).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_ARRAYSIZETHRESHOLD

        public static final int DEFAULT_ARRAYSIZETHRESHOLD
        The default array size threshold value.
        See Also:
        Constant Field Values
      • PROPERTY_MODULE_SCAN

        public static final java.lang.String PROPERTY_MODULE_SCAN
        The property used to enable module scan.
        See Also:
        Constant Field Values
      • PROPERTY_USE_BEAN_INTROSPECTION

        public static final java.lang.String PROPERTY_USE_BEAN_INTROSPECTION
        The property used to enable bean introspection.
        See Also:
        Constant Field Values
    • Constructor Detail

      • JacksonConfiguration

        public JacksonConfiguration()
    • Method Detail

      • isBeanIntrospectionModule

        public boolean isBeanIntrospectionModule()
        Whether the BeanIntrospection should be used for reflection free object serialialization/deserialialization.
        Returns:
        True if it should
      • setBeanIntrospectionModule

        public void setBeanIntrospectionModule​(boolean beanIntrospectionModule)
        Whether the BeanIntrospection should be used for reflection free object serialialization/deserialialization.
        Parameters:
        beanIntrospectionModule - True if it should
      • isModuleScan

        public boolean isModuleScan()
        Whether Jackson modules should be scanned for.
        Returns:
        True if module scanning is enabled
      • setModuleScan

        public void setModuleScan​(boolean moduleScan)
        Sets whether to scan for modules or not (defaults to true).
        Parameters:
        moduleScan - True if module scan should be enabled
      • getSerializationInclusion

        public com.fasterxml.jackson.annotation.JsonInclude.Include getSerializationInclusion()
        Returns:
        The default serialization inclusion settings
      • getDefaultTyping

        public com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping getDefaultTyping()
        Returns:
        The global defaultTyping using for Polymorphic handling
      • getLocale

        public java.util.Locale getLocale()
        Returns:
        The default locale to use
      • getTimeZone

        public java.util.TimeZone getTimeZone()
        Returns:
        The default time zone to use
      • getDateFormat

        public java.lang.String getDateFormat()
        Returns:
        The date format to use for dates
      • getSerializationSettings

        public java.util.Map<com.fasterxml.jackson.databind.SerializationFeature,​java.lang.Boolean> getSerializationSettings()
        Returns:
        The serialization settings
      • getDeserializationSettings

        public java.util.Map<com.fasterxml.jackson.databind.DeserializationFeature,​java.lang.Boolean> getDeserializationSettings()
        Returns:
        The deserialization settings
      • getMapperSettings

        public java.util.Map<com.fasterxml.jackson.databind.MapperFeature,​java.lang.Boolean> getMapperSettings()
        Returns:
        Settings for the object mapper
      • getParserSettings

        public java.util.Map<com.fasterxml.jackson.core.JsonParser.Feature,​java.lang.Boolean> getParserSettings()
        Returns:
        Settings for the parser
      • getGeneratorSettings

        public java.util.Map<com.fasterxml.jackson.core.JsonGenerator.Feature,​java.lang.Boolean> getGeneratorSettings()
        Returns:
        Settings for the generator
      • getFactorySettings

        public java.util.Map<com.fasterxml.jackson.core.JsonFactory.Feature,​java.lang.Boolean> getFactorySettings()
        Returns:
        Settings for the factory
      • getArraySizeThreshold

        public int getArraySizeThreshold()
        Specified by:
        getArraySizeThreshold in interface io.micronaut.json.JsonConfiguration
        Returns:
        The array size threshold to use when using Jackson for data binding
      • getPropertyNamingStrategy

        public com.fasterxml.jackson.databind.PropertyNamingStrategy getPropertyNamingStrategy()
        Returns:
        The property naming strategy
      • isAlwaysSerializeErrorsAsList

        public boolean isAlwaysSerializeErrorsAsList()
        Whether _embedded.errors should always be serialized as list. If set to false, _embedded.errors with 1 element will be serialized as an object.
        Specified by:
        isAlwaysSerializeErrorsAsList in interface io.micronaut.json.JsonConfiguration
        Returns:
        True if _embedded.errors should always be serialized as list.
      • isTrimStrings

        public boolean isTrimStrings()
        Whether strings should be trimmed when deserializing. If the resulting string is an empty string, then null will be applied instead.
        Returns:
        True if strings should be trimmed when deserializing.
      • setDateFormat

        public void setDateFormat​(java.lang.String dateFormat)
        Sets the default date format to use.
        Parameters:
        dateFormat - The date format
      • setLocale

        public void setLocale​(java.util.Locale locale)
        Sets the locale to use.
        Parameters:
        locale - The locale
      • setTimeZone

        public void setTimeZone​(java.util.TimeZone timeZone)
        Sets the timezone to use.
        Parameters:
        timeZone - The timezone
      • setArraySizeThreshold

        public void setArraySizeThreshold​(int arraySizeThreshold)
        Sets the array size threshold for data binding. Default value (100).
        Parameters:
        arraySizeThreshold - The array size threshold
      • setSerialization

        public void setSerialization​(java.util.Map<com.fasterxml.jackson.databind.SerializationFeature,​java.lang.Boolean> serialization)
        Sets the serialization features to use.
        Parameters:
        serialization - The serialization features.
      • setDeserialization

        public void setDeserialization​(java.util.Map<com.fasterxml.jackson.databind.DeserializationFeature,​java.lang.Boolean> deserialization)
        Sets the deserialization features to use.
        Parameters:
        deserialization - The deserialiation features.
      • setMapper

        public void setMapper​(java.util.Map<com.fasterxml.jackson.databind.MapperFeature,​java.lang.Boolean> mapper)
        Sets the object mapper features to use.
        Parameters:
        mapper - The object mapper features
      • setParser

        public void setParser​(java.util.Map<com.fasterxml.jackson.core.JsonParser.Feature,​java.lang.Boolean> parser)
        Sets the parser features to use.
        Parameters:
        parser - The parser features
      • setGenerator

        public void setGenerator​(java.util.Map<com.fasterxml.jackson.core.JsonGenerator.Feature,​java.lang.Boolean> generator)
        Sets the generator features to use.
        Parameters:
        generator - The generator features
      • setFactory

        public void setFactory​(java.util.Map<com.fasterxml.jackson.core.JsonFactory.Feature,​java.lang.Boolean> factory)
        Sets the factory features to use.
        Parameters:
        factory - The generator features
      • setSerializationInclusion

        public void setSerializationInclusion​(com.fasterxml.jackson.annotation.JsonInclude.Include serializationInclusion)
        Sets the serialization inclusion mode.
        Parameters:
        serializationInclusion - The serialization inclusion mode
      • setDefaultTyping

        public void setDefaultTyping​(com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping defaultTyping)
        Sets the global defaultTyping using for Polymorphic handling.
        Parameters:
        defaultTyping - The defaultTyping
      • setPropertyNamingStrategy

        public void setPropertyNamingStrategy​(com.fasterxml.jackson.databind.PropertyNamingStrategy propertyNamingStrategy)
        Sets the property naming strategy.
        Parameters:
        propertyNamingStrategy - The property naming strategy
      • setAlwaysSerializeErrorsAsList

        public void setAlwaysSerializeErrorsAsList​(boolean alwaysSerializeErrorsAsList)
        Sets whether _embedded.errors should always be serialized as list (defaults to false). If set to false, _embedded.errors with 1 element will be serialized as an object.
        Parameters:
        alwaysSerializeErrorsAsList - True if _embedded.errors should always be serialized as list
      • setTrimStrings

        public void setTrimStrings​(boolean trimStrings)
        Whether strings should be trimmed when deserializing (defaults to false). If the resulting string is an empty string, then null will be applied instead.
        Parameters:
        trimStrings - True if strings should be trimmed when deserializing
      • constructType

        public static <T> com.fasterxml.jackson.databind.JavaType constructType​(@NonNull
                                                                                io.micronaut.core.type.Argument<T> type,
                                                                                @NonNull
                                                                                com.fasterxml.jackson.databind.type.TypeFactory typeFactory)
        Constructors a JavaType for the given argument and type factory.
        Type Parameters:
        T - The generic type
        Parameters:
        type - The type
        typeFactory - The type factory
        Returns:
        The JavaType