Package io.micronaut.jackson
Class JacksonConfiguration
java.lang.Object
io.micronaut.jackson.JacksonConfiguration
- All Implemented Interfaces:
JsonConfiguration
@ConfigurationProperties("jackson")
public class JacksonConfiguration
extends Object
implements JsonConfiguration
Configuration for the Jackson JSON parser.
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> com.fasterxml.jackson.databind.JavaTypeconstructType(@NonNull Argument<T> type, @NonNull com.fasterxml.jackson.databind.type.TypeFactory typeFactory) Constructors a JavaType for the given argument and type factory.intcom.fasterxml.jackson.databind.ObjectMapper.DefaultTypingcom.fasterxml.jackson.databind.PropertyNamingStrategycom.fasterxml.jackson.annotation.JsonInclude.IncludebooleanWhether _embedded.errors should always be serialized as list.booleanWhether theBeanIntrospectionshould be used for reflection free object serialialization/deserialialization.booleanWhether Jackson modules should be scanned for.booleanWhether 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(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(Map<com.fasterxml.jackson.databind.DeserializationFeature, Boolean> deserialization) Sets the deserialization features to use.voidsetFactory(Map<com.fasterxml.jackson.core.JsonFactory.Feature, Boolean> factory) Sets the factory features to use.voidsetGenerator(Map<com.fasterxml.jackson.core.JsonGenerator.Feature, Boolean> generator) Sets the generator features to use.voidSets the locale to use.voidSets the object mapper features to use.voidsetModuleScan(boolean moduleScan) Sets whether to scan for modules or not (defaults to true).voidSets the parser features to use.voidsetPropertyNamingStrategy(com.fasterxml.jackson.databind.PropertyNamingStrategy propertyNamingStrategy) Sets the property naming strategy.voidsetSerialization(Map<com.fasterxml.jackson.databind.SerializationFeature, Boolean> serialization) Sets the serialization features to use.voidsetSerializationInclusion(com.fasterxml.jackson.annotation.JsonInclude.Include serializationInclusion) Sets the serialization inclusion mode.voidsetTimeZone(TimeZone timeZone) Sets the timezone to use.voidsetTrimStrings(boolean trimStrings) Whether strings should be trimmed when deserializing (defaults to false).
-
Field Details
-
DEFAULT_ARRAYSIZETHRESHOLD
public static final int DEFAULT_ARRAYSIZETHRESHOLDThe default array size threshold value.- See Also:
-
PROPERTY_MODULE_SCAN
The property used to enable module scan.- See Also:
-
PROPERTY_USE_BEAN_INTROSPECTION
The property used to enable bean introspection.- See Also:
-
-
Constructor Details
-
JacksonConfiguration
public JacksonConfiguration()
-
-
Method Details
-
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
- Returns:
- The default locale to use
-
getTimeZone
- Returns:
- The default time zone to use
-
getDateFormat
- Returns:
- The date format to use for dates
-
getSerializationSettings
- Returns:
- The serialization settings
-
getDeserializationSettings
public Map<com.fasterxml.jackson.databind.DeserializationFeature,Boolean> getDeserializationSettings()- Returns:
- The deserialization settings
-
getMapperSettings
- Returns:
- Settings for the object mapper
-
getParserSettings
- Returns:
- Settings for the parser
-
getGeneratorSettings
- Returns:
- Settings for the generator
-
getFactorySettings
- Returns:
- Settings for the factory
-
getArraySizeThreshold
public int getArraySizeThreshold()- Specified by:
getArraySizeThresholdin interfaceJsonConfiguration- 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 interfaceJsonConfiguration- 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
Sets the default date format to use.- Parameters:
dateFormat- The date format
-
setLocale
Sets the locale to use.- Parameters:
locale- The locale
-
setTimeZone
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(Map<com.fasterxml.jackson.databind.SerializationFeature, Boolean> serialization) Sets the serialization features to use.- Parameters:
serialization- The serialization features.
-
setDeserialization
public void setDeserialization(Map<com.fasterxml.jackson.databind.DeserializationFeature, Boolean> deserialization) Sets the deserialization features to use.- Parameters:
deserialization- The deserialiation features.
-
setMapper
Sets the object mapper features to use.- Parameters:
mapper- The object mapper features
-
setParser
Sets the parser features to use.- Parameters:
parser- The parser features
-
setGenerator
Sets the generator features to use.- Parameters:
generator- The generator features
-
setFactory
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 @NonNull Argument<T> type, @NonNull @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
-