Package org.eclipse.yasson
Class YassonConfig
- java.lang.Object
-
- javax.json.bind.JsonbConfig
-
- org.eclipse.yasson.YassonConfig
-
public class YassonConfig extends javax.json.bind.JsonbConfigCustom properties for configuring Yasson outside of the specificationJsonbConfigscope.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringEAGER_PARSE_CLASSESstatic java.lang.StringFAIL_ON_UNKNOWN_PROPERTIESstatic java.lang.StringNULL_ROOT_SERIALIZERstatic java.lang.StringUSER_TYPE_MAPPINGstatic java.lang.StringZERO_TIME_PARSE_DEFAULTING
-
Constructor Summary
Constructors Constructor Description YassonConfig()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description YassonConfigwithEagerParsing(java.lang.Class<?>... classes)YassonConfigwithFailOnUnknownProperties(boolean failOnUnknownProperties)Property used to specify behaviour on deserialization when JSON document contains properties which doesn't exist in the target class.YassonConfigwithNullRootSerializer(javax.json.bind.serializer.JsonbSerializer<?> nullSerializer)Serializer to use when object provided toJsonb.toJson(Object)isnullor an empty Optional.YassonConfigwithUserTypeMapping(java.util.Map<java.lang.Class<?>,java.lang.Class<?>> mapping)User type mapping for map interface to implementation classes.YassonConfigwithZeroTimeParseDefaulting(boolean defaultZeroHour)Makes parsing dates defaulting to zero hour, minute and second.-
Methods inherited from class javax.json.bind.JsonbConfig
getAsMap, getProperty, setProperty, withAdapters, withBinaryDataStrategy, withDateFormat, withDeserializers, withEncoding, withFormatting, withLocale, withNullValues, withPropertyNamingStrategy, withPropertyNamingStrategy, withPropertyOrderStrategy, withPropertyVisibilityStrategy, withSerializers, withStrictIJSON
-
-
-
-
Field Detail
-
FAIL_ON_UNKNOWN_PROPERTIES
public static final java.lang.String FAIL_ON_UNKNOWN_PROPERTIES
-
USER_TYPE_MAPPING
public static final java.lang.String USER_TYPE_MAPPING
-
ZERO_TIME_PARSE_DEFAULTING
public static final java.lang.String ZERO_TIME_PARSE_DEFAULTING
-
NULL_ROOT_SERIALIZER
public static final java.lang.String NULL_ROOT_SERIALIZER
-
EAGER_PARSE_CLASSES
public static final java.lang.String EAGER_PARSE_CLASSES
- See Also:
withEagerParsing(Class...), Constant Field Values
-
-
Method Detail
-
withFailOnUnknownProperties
public YassonConfig withFailOnUnknownProperties(boolean failOnUnknownProperties)
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
public YassonConfig withUserTypeMapping(java.util.Map<java.lang.Class<?>,java.lang.Class<?>> mapping)
User type mapping for map interface to implementation classes.- Parameters:
mapping- A map of interface to implementation class mappings- Returns:
- This YassonConfig instance
-
withZeroTimeParseDefaulting
public YassonConfig withZeroTimeParseDefaulting(boolean defaultZeroHour)
Makes parsing dates defaulting to zero hour, minute and second. This will made available to parse patterns like yyyy.MM.dd to
Date,Calendar,InstantLocalDateor 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
InstantorZonedDateTime.- Parameters:
defaultZeroHour- Whether or not to default parsing dates to the zero hour- Returns:
- This YassonConfig instance
-
withNullRootSerializer
public YassonConfig withNullRootSerializer(javax.json.bind.serializer.JsonbSerializer<?> nullSerializer)
Serializer to use when object provided toJsonb.toJson(Object)isnullor 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
public YassonConfig withEagerParsing(java.lang.Class<?>... classes)
- Parameters:
classes- A list of classes to eagerly parse upon creation of the Jsonb instance used with this configuration.- Returns:
- This YassonConfig instance
-
-