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
FieldsModifier and TypeFieldDescriptionstatic final intThe default array size threshold value.static final StringThe property used to enable module scan. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> tools.jackson.databind.JavaTypeconstructType(@NonNull Argument<T> type, @NonNull tools.jackson.databind.type.TypeFactory typeFactory) Constructors a JavaType for the given argument and type factory.intDate/time data binding features.tools.jackson.databind.DefaultTypingGeneral deserialization features.Enum data binding features.JSON factory features.JsonNode data binding features.JSON stream read features.JSON stream write features.General mapper features.tools.jackson.databind.PropertyNamingStrategyGeneral serialization features.com.fasterxml.jackson.annotation.JsonInclude.IncludeFormat-independent stream read features.Format-independent stream write features.booleanWhether _embedded.errors should always be serialized as list.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.voidsetDateFormat(String dateFormat) Sets the default date format to use.voidsetDateTimeFeatures(Map<tools.jackson.databind.cfg.DateTimeFeature, Boolean> dateTimeFeatures) Date/time data binding features.voidsetDefaultTyping(tools.jackson.databind.DefaultTyping defaultTyping) Sets the global defaultTyping using for Polymorphic handling.voidsetDeserializationFeatures(Map<tools.jackson.databind.DeserializationFeature, Boolean> deserializationFeatures) Sets the deserialization features to use.voidsetEnumFeatures(Map<tools.jackson.databind.cfg.EnumFeature, Boolean> enumFeatures) Enum data binding features.voidsetJsonFactoryFeatures(Map<tools.jackson.core.TokenStreamFactory.Feature, Boolean> jsonFactoryFeatures) JSON factory features.voidsetJsonNodeFeatures(Map<tools.jackson.databind.cfg.JsonNodeFeature, Boolean> jsonNodeFeatures) JsonNode data binding features.voidsetJsonReadFeatures(Map<tools.jackson.core.json.JsonReadFeature, Boolean> jsonReadFeatures) JSON stream read features.voidsetJsonWriteFeatures(Map<tools.jackson.core.json.JsonWriteFeature, Boolean> jsonWriteFeatures) JSON stream write features.voidSets the locale to use.voidsetMapperFeatures(Map<tools.jackson.databind.MapperFeature, Boolean> mapperFeatures) Sets the object mapper features to use.voidsetModuleScan(boolean moduleScan) Sets whether to scan for modules or not (defaults to true).voidsetPropertyNamingStrategy(tools.jackson.databind.PropertyNamingStrategy propertyNamingStrategy) Sets the property naming strategy.voidsetSerializationFeatures(Map<tools.jackson.databind.SerializationFeature, Boolean> serializationFeatures) Sets the serialization features to use.voidsetSerializationInclusion(com.fasterxml.jackson.annotation.JsonInclude.Include serializationInclusion) Sets the serialization inclusion mode.voidsetStreamReadFeatures(Map<tools.jackson.core.StreamReadFeature, Boolean> streamReadFeatures) Format-independent stream read features.voidsetStreamWriteFeatures(Map<tools.jackson.core.StreamWriteFeature, Boolean> streamWriteFeatures) Format-independent stream write features.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:
-
-
Constructor Details
-
JacksonConfiguration
public JacksonConfiguration()
-
-
Method Details
-
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 tools.jackson.databind.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
-
getArraySizeThreshold
public int getArraySizeThreshold()- Specified by:
getArraySizeThresholdin interfaceJsonConfiguration- Returns:
- The array size threshold to use when using Jackson for data binding
-
getPropertyNamingStrategy
public tools.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
-
setSerializationFeatures
public void setSerializationFeatures(Map<tools.jackson.databind.SerializationFeature, Boolean> serializationFeatures) Sets the serialization features to use.- Parameters:
serializationFeatures- The serialization features.
-
setDeserializationFeatures
public void setDeserializationFeatures(Map<tools.jackson.databind.DeserializationFeature, Boolean> deserializationFeatures) Sets the deserialization features to use.- Parameters:
deserializationFeatures- The deserialiation features.
-
setMapperFeatures
Sets the object mapper features to use.- Parameters:
mapperFeatures- The object mapper features
-
getStreamWriteFeatures
Format-independent stream write features.- Returns:
- The stream write features
-
setStreamWriteFeatures
public void setStreamWriteFeatures(Map<tools.jackson.core.StreamWriteFeature, Boolean> streamWriteFeatures) Format-independent stream write features.- Parameters:
streamWriteFeatures- The stream write features
-
getStreamReadFeatures
Format-independent stream read features.- Returns:
- The stream read features
-
setStreamReadFeatures
public void setStreamReadFeatures(Map<tools.jackson.core.StreamReadFeature, Boolean> streamReadFeatures) Format-independent stream read features.- Parameters:
streamReadFeatures- The stream read features
-
getJsonFactoryFeatures
JSON factory features.- Returns:
- JSON factory features
-
setJsonFactoryFeatures
public void setJsonFactoryFeatures(Map<tools.jackson.core.TokenStreamFactory.Feature, Boolean> jsonFactoryFeatures) JSON factory features.- Parameters:
jsonFactoryFeatures- JSON factory features
-
getJsonWriteFeatures
JSON stream write features.- Returns:
- JSON stream write features
-
setJsonWriteFeatures
public void setJsonWriteFeatures(Map<tools.jackson.core.json.JsonWriteFeature, Boolean> jsonWriteFeatures) JSON stream write features.- Parameters:
jsonWriteFeatures- JSON stream write features
-
getJsonReadFeatures
JSON stream read features.- Returns:
- JSON stream read features
-
setJsonReadFeatures
public void setJsonReadFeatures(Map<tools.jackson.core.json.JsonReadFeature, Boolean> jsonReadFeatures) JSON stream read features.- Parameters:
jsonReadFeatures- JSON stream read features
-
getMapperFeatures
General mapper features.- Returns:
- General mapper features
-
getDeserializationFeatures
General deserialization features.- Returns:
- General deserialization features
-
getSerializationFeatures
General serialization features.- Returns:
- General serialization features
-
getEnumFeatures
Enum data binding features.- Returns:
- Enum data binding features
-
setEnumFeatures
Enum data binding features.- Parameters:
enumFeatures- Enum data binding features
-
getDateTimeFeatures
Date/time data binding features.- Returns:
- Date/time data binding features
-
setDateTimeFeatures
public void setDateTimeFeatures(Map<tools.jackson.databind.cfg.DateTimeFeature, Boolean> dateTimeFeatures) Date/time data binding features.- Parameters:
dateTimeFeatures- Date/time data binding features
-
getJsonNodeFeatures
JsonNode data binding features.- Returns:
- JsonNode data binding features
-
setJsonNodeFeatures
public void setJsonNodeFeatures(Map<tools.jackson.databind.cfg.JsonNodeFeature, Boolean> jsonNodeFeatures) JsonNode data binding features.- Parameters:
jsonNodeFeatures- JsonNode data binding 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(tools.jackson.databind.DefaultTyping defaultTyping) Sets the global defaultTyping using for Polymorphic handling.- Parameters:
defaultTyping- The defaultTyping
-
setPropertyNamingStrategy
public void setPropertyNamingStrategy(tools.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> tools.jackson.databind.JavaType constructType(@NonNull Argument<T> type, @NonNull tools.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
-