java.lang.Object
jakarta.json.bind.JsonbConfig
org.eclipse.yasson.YassonConfig
public class YassonConfig
extends jakarta.json.bind.JsonbConfig
Custom properties for configuring Yasson outside of the specification
JsonbConfig
scope.-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class jakarta.json.bind.JsonbConfig
ADAPTERS, BINARY_DATA_STRATEGY, CREATOR_PARAMETERS_REQUIRED, DATE_FORMAT, DESERIALIZERS, ENCODING, FORMATTING, LOCALE, NULL_VALUES, PROPERTY_NAMING_STRATEGY, PROPERTY_ORDER_STRATEGY, PROPERTY_VISIBILITY_STRATEGY, SERIALIZERS, STRICT_IJSON
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionwithEagerParsing
(Class<?>... classes) withFailOnUnknownProperties
(boolean failOnUnknownProperties) Property used to specify behaviour on deserialization when JSON document contains properties which doesn't exist in the target class.withForceMapArraySerializerForNullKeys
(boolean value) Property needed to make MapToEntriesArraySerializer the serializer used when a null key is found in the map.withNullRootSerializer
(jakarta.json.bind.serializer.JsonbSerializer<?> nullSerializer) Serializer to use when object provided toJsonb.toJson(Object)
isnull
or an empty Optional.withTimeInMillisAsAString
(boolean value) It is required to handle time millisecond format as a number.withUserTypeMapping
(Map<Class<?>, Class<?>> mapping) User type mapping for map interface to implementation classes.withZeroTimeParseDefaulting
(boolean defaultZeroHour) Makes parsing dates defaulting to zero hour, minute and second.Methods inherited from class jakarta.json.bind.JsonbConfig
getAsMap, getProperty, setProperty, withAdapters, withBinaryDataStrategy, withCreatorParametersRequired, withDateFormat, withDeserializers, withEncoding, withFormatting, withLocale, withNullValues, withPropertyNamingStrategy, withPropertyNamingStrategy, withPropertyOrderStrategy, withPropertyVisibilityStrategy, withSerializers, withStrictIJSON
-
Field Details
-
FAIL_ON_UNKNOWN_PROPERTIES
-
USER_TYPE_MAPPING
-
ZERO_TIME_PARSE_DEFAULTING
-
NULL_ROOT_SERIALIZER
-
EAGER_PARSE_CLASSES
-
FORCE_MAP_ARRAY_SERIALIZER_FOR_NULL_KEYS
-
DATE_TIME_IN_MILLIS_AS_A_STRING
-
-
Constructor Details
-
YassonConfig
public YassonConfig()
-
-
Method Details
-
withFailOnUnknownProperties
Property used to specify behaviour on deserialization when JSON document contains properties which doesn't exist in the target class. Default value is 'false'.- Parameters:
failOnUnknownProperties
- Whether or not to fail if unknown properties are encountered- Returns:
- This YassonConfig instance
-
withUserTypeMapping
User type mapping for map interface to implementation classes.- Parameters:
mapping
- A map of interface to implementation class mappings- Returns:
- This YassonConfig instance
-
withZeroTimeParseDefaulting
Makes parsing dates defaulting to zero hour, minute and second. This will made available to parse patterns like yyyy.MM.dd to
Date
,Calendar
,Instant
LocalDate
or evenZonedDateTime
.If time zone is not set in the pattern then UTC time zone is used. So for example json value 2018.01.01 becomes 2018.01.01 00:00:00 UTC when parsed to instant
Instant
orZonedDateTime
.- Parameters:
defaultZeroHour
- Whether or not to default parsing dates to the zero hour- Returns:
- This YassonConfig instance
-
withNullRootSerializer
public YassonConfig withNullRootSerializer(jakarta.json.bind.serializer.JsonbSerializer<?> nullSerializer) Serializer to use when object provided toJsonb.toJson(Object)
isnull
or an empty Optional. Must be instance ofJsonbSerializer
<Object>
. Its obj value will be respective parameter.- Parameters:
nullSerializer
- JsonbSerializer instance to use for serializing null root values- Returns:
- This YassonConfig instance
-
withEagerParsing
- Parameters:
classes
- A list of classes to eagerly parse upon creation of the Jsonb instance used with this configuration.- Returns:
- This YassonConfig instance
-
withForceMapArraySerializerForNullKeys
Property needed to make MapToEntriesArraySerializer the serializer used when a null key is found in the map. Default value is false.- Parameters:
value
- true to force the use of the MapToEntriesArraySerializer if a null key is detected in the map, false to work as before- Returns:
- This YassonConfig instance
-
withTimeInMillisAsAString
It is required to handle time millisecond format as a number. SeeJsonbDateFormat.TIME_IN_MILLIS
. It is possible to override this and force Yasson to handle it as a String, by using this method.- Parameters:
value
- whether to treat dates formatted byJsonbDateFormat.TIME_IN_MILLIS
as a String. Default value isfalse
.- Returns:
- This YassonConfig instance
- Since:
- 3.0.0
-