public class JsonbConfig
extends java.lang.Object
This object is not thread safe. Implementations are expected to make a defensive copy of the object before applying the configuration.All JSON Binding providers are required to support the following set of properties. Some providers may support additional properties.
jsonb.to.json.formatted
- java.lang.Boolean- Controls whether or not the
Jsonb
toJson()
methods will format the resulting JSON data with line breaks and indentation. A true value for this property indicates human readable indented data, while a false value indicates unformatted data. Default value is false (unformatted) if this property is not specified.
jsonb.to.json.encoding
- java.lang.String- The
Jsonb
serializationtoJson()
methods will default to this property for encoding of output JSON data. Default value is 'UTF-8' if this property is not specified.
jsonb.from.json.encoding
- java.lang.String- The
Jsonb
deserializationfromJson()
methods will default to this property encoding of input JSON data if the encoding cannot be detected.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ADAPTERS
Property used to specify custom mapping adapters for generic types.
|
static java.lang.String |
BINARY_DATA_STRATEGY
Property used to specify custom binary data strategy.
|
static java.lang.String |
DATE_FORMAT
Property used to specify custom date format globally.
|
static java.lang.String |
DESERIALIZERS
Property used to specify custom deserializers.
|
static java.lang.String |
ENCODING
The Jsonb serialization
toJson() methods will default to this property
for encoding of output JSON data. |
static java.lang.String |
FORMATTING
Property used to specify whether or not the serialized
JSON data is formatted with line feeds and indentation.
|
static java.lang.String |
LOCALE
Property used to specify locale globally.
|
static java.lang.String |
NULL_VALUES
Property used to specify null values serialization behavior.
|
static java.lang.String |
PROPERTY_NAMING_STRATEGY
Property used to specify custom naming strategy.
|
static java.lang.String |
PROPERTY_ORDER_STRATEGY
Property used to specify custom order strategy.
|
static java.lang.String |
PROPERTY_VISIBILITY_STRATEGY
Property used to specify custom visibility strategy.
|
static java.lang.String |
SERIALIZERS
Property used to specify custom serializers.
|
static java.lang.String |
STRICT_IJSON
Property used to specify strict I-JSON serialization compliance.
|
Constructor and Description |
---|
JsonbConfig() |
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,java.lang.Object> |
getAsMap()
Return all configuration properties as an unmodifiable map.
|
java.util.Optional<java.lang.Object> |
getProperty(java.lang.String name)
Return value of particular configuration property.
|
JsonbConfig |
setProperty(java.lang.String name,
java.lang.Object value)
Set the particular configuration property to a new value.
|
JsonbConfig |
withAdapters(JsonbAdapter... adapters)
Property used to specify custom mapping adapters.
|
JsonbConfig |
withBinaryDataStrategy(java.lang.String binaryDataStrategy)
Property used to specify custom binary data strategy.
|
JsonbConfig |
withDateFormat(java.lang.String dateFormat,
java.util.Locale locale)
Property used to specify custom date format.
|
JsonbConfig |
withDeserializers(JsonbDeserializer... deserializers)
Property used to specify custom deserializers.
|
JsonbConfig |
withEncoding(java.lang.String encoding)
The binding operations will default to this property
for encoding of JSON data.
|
JsonbConfig |
withFormatting(java.lang.Boolean formatted)
Property used to specify whether or not the serialized JSON data is formatted
with linefeeds and indentation.
|
JsonbConfig |
withLocale(java.util.Locale locale)
Property used to specify custom locale.
|
JsonbConfig |
withNullValues(java.lang.Boolean serializeNullValues)
Property used to specify whether null values should be serialized to JSON document or skipped.
|
JsonbConfig |
withPropertyNamingStrategy(PropertyNamingStrategy propertyNamingStrategy)
Property used to specify custom naming strategy.
|
JsonbConfig |
withPropertyNamingStrategy(java.lang.String propertyNamingStrategy)
Property used to specify custom naming strategy.
|
JsonbConfig |
withPropertyOrderStrategy(java.lang.String propertyOrderStrategy)
Property used to specify property order strategy.
|
JsonbConfig |
withPropertyVisibilityStrategy(PropertyVisibilityStrategy propertyVisibilityStrategy)
Property used to specify custom property visibility strategy.
|
JsonbConfig |
withSerializers(JsonbSerializer... serializers)
Property used to specify custom serializers.
|
JsonbConfig |
withStrictIJSON(java.lang.Boolean enabled)
Property used to specify whether strict I-JSON serialization compliance should be enforced.
|
public static final java.lang.String FORMATTING
public static final java.lang.String ENCODING
toJson()
methods will default to this property
for encoding of output JSON data. Default value is 'UTF-8'.
The Jsonb deserialization fromJson()
methods will default to this
property encoding of input JSON data if the encoding cannot be detected
automatically.public static final java.lang.String PROPERTY_NAMING_STRATEGY
public static final java.lang.String PROPERTY_ORDER_STRATEGY
public static final java.lang.String NULL_VALUES
public static final java.lang.String STRICT_IJSON
public static final java.lang.String PROPERTY_VISIBILITY_STRATEGY
public static final java.lang.String ADAPTERS
public static final java.lang.String SERIALIZERS
public static final java.lang.String DESERIALIZERS
public static final java.lang.String BINARY_DATA_STRATEGY
public static final java.lang.String DATE_FORMAT
public static final java.lang.String LOCALE
public final JsonbConfig setProperty(java.lang.String name, java.lang.Object value)
name
- The name of the property to be set. This value can either
be specified using one of the constant fields or a user supplied
string.value
- The value of the property to be setjava.lang.NullPointerException
- if the name parameter is null.public final java.util.Optional<java.lang.Object> getProperty(java.lang.String name)
name
- The name of the property to retrievejava.lang.NullPointerException
- if the name parameter is null.public final java.util.Map<java.lang.String,java.lang.Object> getAsMap()
public final JsonbConfig withFormatting(java.lang.Boolean formatted)
FORMATTING
property.formatted
- True means serialized data is formatted, false (default)
means no formatting.public final JsonbConfig withNullValues(java.lang.Boolean serializeNullValues)
NULL_VALUES
property.serializeNullValues
- True means that null values will be serialized into JSON document,
otherwise they will be effectively skipped.public final JsonbConfig withEncoding(java.lang.String encoding)
ENCODING
property.encoding
- Valid character encoding as defined in the
RFC 7159 and supported by
Java Platform.public final JsonbConfig withStrictIJSON(java.lang.Boolean enabled)
STRICT_IJSON
property.enabled
- True means data is serialized in strict compliance according to RFC 7493.public final JsonbConfig withPropertyNamingStrategy(PropertyNamingStrategy propertyNamingStrategy)
JSONB_PROPERTY_NAMING_STRATEGY
property.propertyNamingStrategy
- Custom naming strategy which affects serialization and deserialization.public final JsonbConfig withPropertyNamingStrategy(java.lang.String propertyNamingStrategy)
JSONB_PROPERTY_NAMING_STRATEGY
property.propertyNamingStrategy
- Predefined naming strategy which affects serialization and deserialization.public final JsonbConfig withPropertyOrderStrategy(java.lang.String propertyOrderStrategy)
JSONB_PROPERTY_ORDER_STRATEGY
property.propertyOrderStrategy
- Predefined property order strategy which affects serialization.public final JsonbConfig withPropertyVisibilityStrategy(PropertyVisibilityStrategy propertyVisibilityStrategy)
PROPERTY_VISIBILITY_STRATEGY
property.propertyVisibilityStrategy
- Custom property visibility strategy which affects serialization and deserialization.public final JsonbConfig withAdapters(JsonbAdapter... adapters)
ADAPTERS
property.
Calling withAdapters more than once will merge the adapters with previous value.adapters
- Custom mapping adapters which affects serialization and deserialization.public final JsonbConfig withSerializers(JsonbSerializer... serializers)
SERIALIZERS
property.
Calling withSerializers more than once will merge the serializers with previous value.serializers
- Custom serializers which affects serialization.public final JsonbConfig withDeserializers(JsonbDeserializer... deserializers)
DESERIALIZERS
property.
Calling withDeserializers more than once will merge the deserializers with previous value.deserializers
- Custom deserializers which affects deserialization.public final JsonbConfig withBinaryDataStrategy(java.lang.String binaryDataStrategy)
BINARY_DATA_STRATEGY
property.binaryDataStrategy
- Custom binary data strategy which affects serialization and deserialization.public final JsonbConfig withDateFormat(java.lang.String dateFormat, java.util.Locale locale)
dateFormat
- Custom date format as specified in DateTimeFormatter
.locale
- Locale, default is null.public final JsonbConfig withLocale(java.util.Locale locale)
locale
- Locale, must not be null.