Package io.micronaut.jackson
Class JacksonConfiguration
- java.lang.Object
-
- io.micronaut.jackson.JacksonConfiguration
-
- All Implemented Interfaces:
io.micronaut.json.JsonConfiguration
@ConfigurationProperties("jackson") public class JacksonConfiguration extends java.lang.Object implements io.micronaut.json.JsonConfigurationConfiguration for the Jackson JSON parser.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_ARRAYSIZETHRESHOLDThe default array size threshold value.static java.lang.StringPROPERTY_MODULE_SCANThe property used to enable module scan.static java.lang.StringPROPERTY_USE_BEAN_INTROSPECTIONThe property used to enable bean introspection.
-
Constructor Summary
Constructors Constructor Description JacksonConfiguration()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> com.fasterxml.jackson.databind.JavaTypeconstructType(io.micronaut.core.type.Argument<T> type, com.fasterxml.jackson.databind.type.TypeFactory typeFactory)Constructors a JavaType for the given argument and type factory.intgetArraySizeThreshold()java.lang.StringgetDateFormat()com.fasterxml.jackson.databind.ObjectMapper.DefaultTypinggetDefaultTyping()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.LocalegetLocale()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.PropertyNamingStrategygetPropertyNamingStrategy()com.fasterxml.jackson.annotation.JsonInclude.IncludegetSerializationInclusion()java.util.Map<com.fasterxml.jackson.databind.SerializationFeature,java.lang.Boolean>getSerializationSettings()java.util.TimeZonegetTimeZone()booleanisAlwaysSerializeErrorsAsList()Whether _embedded.errors should always be serialized as list.booleanisBeanIntrospectionModule()Whether theBeanIntrospectionshould be used for reflection free object serialialization/deserialialization.booleanisModuleScan()Whether Jackson modules should be scanned for.booleanisTrimStrings()Whether strings should be trimmed when deserializing.voidsetAlwaysSerializeErrorsAsList(boolean alwaysSerializeErrorsAsList)Sets whether _embedded.errors should always be serialized as list (defaults to false).voidsetArraySizeThreshold(int arraySizeThreshold)Sets the array size threshold for data binding.voidsetBeanIntrospectionModule(boolean beanIntrospectionModule)Whether theBeanIntrospectionshould be used for reflection free object serialialization/deserialialization.voidsetDateFormat(java.lang.String dateFormat)Sets the default date format to use.voidsetDefaultTyping(com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping defaultTyping)Sets the global defaultTyping using for Polymorphic handling.voidsetDeserialization(java.util.Map<com.fasterxml.jackson.databind.DeserializationFeature,java.lang.Boolean> deserialization)Sets the deserialization features to use.voidsetFactory(java.util.Map<com.fasterxml.jackson.core.JsonFactory.Feature,java.lang.Boolean> factory)Sets the factory features to use.voidsetGenerator(java.util.Map<com.fasterxml.jackson.core.JsonGenerator.Feature,java.lang.Boolean> generator)Sets the generator features to use.voidsetLocale(java.util.Locale locale)Sets the locale to use.voidsetMapper(java.util.Map<com.fasterxml.jackson.databind.MapperFeature,java.lang.Boolean> mapper)Sets the object mapper features to use.voidsetModuleScan(boolean moduleScan)Sets whether to scan for modules or not (defaults to true).voidsetParser(java.util.Map<com.fasterxml.jackson.core.JsonParser.Feature,java.lang.Boolean> parser)Sets the parser features to use.voidsetPropertyNamingStrategy(com.fasterxml.jackson.databind.PropertyNamingStrategy propertyNamingStrategy)Sets the property naming strategy.voidsetSerialization(java.util.Map<com.fasterxml.jackson.databind.SerializationFeature,java.lang.Boolean> serialization)Sets the serialization features to use.voidsetSerializationInclusion(com.fasterxml.jackson.annotation.JsonInclude.Include serializationInclusion)Sets the serialization inclusion mode.voidsetTimeZone(java.util.TimeZone timeZone)Sets the timezone to use.voidsetTrimStrings(boolean trimStrings)Whether strings should be trimmed when deserializing (defaults to false).
-
-
-
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
-
-
Method Detail
-
isBeanIntrospectionModule
public boolean isBeanIntrospectionModule()
Whether theBeanIntrospectionshould be used for reflection free object serialialization/deserialialization.- Returns:
- True if it should
-
setBeanIntrospectionModule
public void setBeanIntrospectionModule(boolean beanIntrospectionModule)
Whether theBeanIntrospectionshould 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:
getArraySizeThresholdin interfaceio.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:
isAlwaysSerializeErrorsAsListin interfaceio.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 typetypeFactory- The type factory- Returns:
- The JavaType
-
-