Package jakarta.json.bind
Class JsonbConfig
- java.lang.Object
- 
- jakarta.json.bind.JsonbConfig
 
- 
 public class JsonbConfig extends 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 JsonbtoJson()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 JsonbserializationtoJson()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 JsonbdeserializationfromJson()methods will default to this property encoding of input JSON data if the encoding cannot be detected.
 - Since:
- JSON Binding 1.0
 
- 
- 
Field SummaryFields Modifier and Type Field Description static StringADAPTERSProperty used to specify custom mapping adapters for generic types.static StringBINARY_DATA_STRATEGYProperty used to specify custom binary data strategy.static StringCREATOR_PARAMETERS_REQUIREDProperty used to specify required creator parameters.static StringDATE_FORMATProperty used to specify custom date format globally.static StringDESERIALIZERSProperty used to specify custom deserializers.static StringENCODINGThe Jsonb serializationtoJson()methods will default to this property for encoding of output JSON data.static StringFORMATTINGProperty used to specify whether or not the serialized JSON data is formatted with line feeds and indentation.static StringLOCALEProperty used to specify locale globally.static StringNULL_VALUESProperty used to specify null values serialization behavior.static StringPROPERTY_NAMING_STRATEGYProperty used to specify custom naming strategy.static StringPROPERTY_ORDER_STRATEGYProperty used to specify custom order strategy.static StringPROPERTY_VISIBILITY_STRATEGYProperty used to specify custom visibility strategy.static StringSERIALIZERSProperty used to specify custom serializers.static StringSTRICT_IJSONProperty used to specify strict I-JSON serialization compliance.
 - 
Constructor SummaryConstructors Constructor Description JsonbConfig()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,Object>getAsMap()Return all configuration properties as an unmodifiable map.Optional<Object>getProperty(String name)Return value of particular configuration property.JsonbConfigsetProperty(String name, Object value)Set the particular configuration property to a new value.JsonbConfigwithAdapters(JsonbAdapter... adapters)Property used to specify custom mapping adapters.JsonbConfigwithBinaryDataStrategy(String binaryDataStrategy)Property used to specify custom binary data strategy.JsonbConfigwithCreatorParametersRequired(boolean requiredParameters)Property used to specify whether all creator parameters should be treated as required.JsonbConfigwithDateFormat(String dateFormat, Locale locale)Property used to specify custom date format.JsonbConfigwithDeserializers(JsonbDeserializer... deserializers)Property used to specify custom deserializers.JsonbConfigwithEncoding(String encoding)The binding operations will default to this property for encoding of JSON data.JsonbConfigwithFormatting(Boolean formatted)Property used to specify whether or not the serialized JSON data is formatted with linefeeds and indentation.JsonbConfigwithLocale(Locale locale)Property used to specify custom locale.JsonbConfigwithNullValues(Boolean serializeNullValues)Property used to specify whether null values should be serialized to JSON document or skipped.JsonbConfigwithPropertyNamingStrategy(PropertyNamingStrategy propertyNamingStrategy)Property used to specify custom naming strategy.JsonbConfigwithPropertyNamingStrategy(String propertyNamingStrategy)Property used to specify custom naming strategy.JsonbConfigwithPropertyOrderStrategy(String propertyOrderStrategy)Property used to specify property order strategy.JsonbConfigwithPropertyVisibilityStrategy(PropertyVisibilityStrategy propertyVisibilityStrategy)Property used to specify custom property visibility strategy.JsonbConfigwithSerializers(JsonbSerializer... serializers)Property used to specify custom serializers.JsonbConfigwithStrictIJSON(Boolean enabled)Property used to specify whether strict I-JSON serialization compliance should be enforced.
 
- 
- 
- 
Field Detail- 
FORMATTINGpublic static final String FORMATTING Property used to specify whether or not the serialized JSON data is formatted with line feeds and indentation.- See Also:
- Constant Field Values
 
 - 
ENCODINGpublic static final String ENCODING The Jsonb serializationtoJson()methods will default to this property for encoding of output JSON data. Default value is 'UTF-8'. The Jsonb deserializationfromJson()methods will default to this property encoding of input JSON data if the encoding cannot be detected automatically.- See Also:
- Constant Field Values
 
 - 
PROPERTY_NAMING_STRATEGYpublic static final String PROPERTY_NAMING_STRATEGY Property used to specify custom naming strategy.- See Also:
- Constant Field Values
 
 - 
PROPERTY_ORDER_STRATEGYpublic static final String PROPERTY_ORDER_STRATEGY Property used to specify custom order strategy.- See Also:
- Constant Field Values
 
 - 
NULL_VALUESpublic static final String NULL_VALUES Property used to specify null values serialization behavior.- See Also:
- Constant Field Values
 
 - 
STRICT_IJSONpublic static final String STRICT_IJSON Property used to specify strict I-JSON serialization compliance.- See Also:
- Constant Field Values
 
 - 
PROPERTY_VISIBILITY_STRATEGYpublic static final String PROPERTY_VISIBILITY_STRATEGY Property used to specify custom visibility strategy.- See Also:
- Constant Field Values
 
 - 
ADAPTERSpublic static final String ADAPTERS Property used to specify custom mapping adapters for generic types.- See Also:
- Constant Field Values
 
 - 
SERIALIZERSpublic static final String SERIALIZERS Property used to specify custom serializers.- See Also:
- Constant Field Values
 
 - 
DESERIALIZERSpublic static final String DESERIALIZERS Property used to specify custom deserializers.- See Also:
- Constant Field Values
 
 - 
BINARY_DATA_STRATEGYpublic static final String BINARY_DATA_STRATEGY Property used to specify custom binary data strategy.- See Also:
- Constant Field Values
 
 - 
DATE_FORMATpublic static final String DATE_FORMAT Property used to specify custom date format globally.- See Also:
- Constant Field Values
 
 - 
LOCALEpublic static final String LOCALE Property used to specify locale globally.- See Also:
- Constant Field Values
 
 - 
CREATOR_PARAMETERS_REQUIREDpublic static final String CREATOR_PARAMETERS_REQUIRED Property used to specify required creator parameters.- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
setPropertypublic final JsonbConfig setProperty(String name, Object value) Set the particular configuration property to a new value. The method can only be used to set one of the standard JSON Binding properties defined in this class or a provider specific property.- Parameters:
- 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 set
- Returns:
- This JsonbConfig instance.
- Throws:
- NullPointerException- if the name parameter is null.
 
 - 
getPropertypublic final Optional<Object> getProperty(String name) Return value of particular configuration property. The method can only be used to retrieve one of the standard JSON Binding properties defined in this class or a provider specific property. Attempting to get an undefined property will result in an empty Optional value. See Supported Properties.- Parameters:
- name- The name of the property to retrieve
- Returns:
- The value of the requested property
- Throws:
- NullPointerException- if the name parameter is null.
 
 - 
getAsMappublic final Map<String,Object> getAsMap() Return all configuration properties as an unmodifiable map.- Returns:
- All configuration properties as an unmodifiable map
 
 - 
withFormattingpublic final JsonbConfig withFormatting(Boolean formatted) Property used to specify whether or not the serialized JSON data is formatted with linefeeds and indentation. Configures value ofFORMATTINGproperty.- Parameters:
- formatted- True means serialized data is formatted, false (default) means no formatting.
- Returns:
- This JsonbConfig instance.
 
 - 
withNullValuespublic final JsonbConfig withNullValues(Boolean serializeNullValues) Property used to specify whether null values should be serialized to JSON document or skipped. Configures value ofNULL_VALUESproperty.- Parameters:
- serializeNullValues- True means that null values will be serialized into JSON document, otherwise they will be effectively skipped.
- Returns:
- This JsonbConfig instance.
 
 - 
withEncodingpublic final JsonbConfig withEncoding(String encoding) The binding operations will default to this property for encoding of JSON data. For input data (fromJson), selected encoding is used if the encoding cannot be detected automatically. Default value is 'UTF-8'. Configures value ofENCODINGproperty.- Parameters:
- encoding- Valid character encoding as defined in the RFC 7159 and supported by Java Platform.
- Returns:
- This JsonbConfig instance.
 
 - 
withStrictIJSONpublic final JsonbConfig withStrictIJSON(Boolean enabled) Property used to specify whether strict I-JSON serialization compliance should be enforced. Configures value ofSTRICT_IJSONproperty.- Parameters:
- enabled- True means data is serialized in strict compliance according to RFC 7493.
- Returns:
- This JsonbConfig instance.
 
 - 
withPropertyNamingStrategypublic final JsonbConfig withPropertyNamingStrategy(PropertyNamingStrategy propertyNamingStrategy) Property used to specify custom naming strategy. Configures value ofPROPERTY_NAMING_STRATEGYproperty.- Parameters:
- propertyNamingStrategy- Custom naming strategy which affects serialization and deserialization.
- Returns:
- This JsonbConfig instance.
 
 - 
withPropertyNamingStrategypublic final JsonbConfig withPropertyNamingStrategy(String propertyNamingStrategy) Property used to specify custom naming strategy. Configures value ofPROPERTY_NAMING_STRATEGYproperty.- Parameters:
- propertyNamingStrategy- Predefined naming strategy which affects serialization and deserialization.
- Returns:
- This JsonbConfig instance.
 
 - 
withPropertyOrderStrategypublic final JsonbConfig withPropertyOrderStrategy(String propertyOrderStrategy) Property used to specify property order strategy. Configures values ofPROPERTY_ORDER_STRATEGYproperty.- Parameters:
- propertyOrderStrategy- Predefined property order strategy which affects serialization.
- Returns:
- This JsonbConfig instance.
 
 - 
withPropertyVisibilityStrategypublic final JsonbConfig withPropertyVisibilityStrategy(PropertyVisibilityStrategy propertyVisibilityStrategy) Property used to specify custom property visibility strategy. Configures value ofPROPERTY_VISIBILITY_STRATEGYproperty.- Parameters:
- propertyVisibilityStrategy- Custom property visibility strategy which affects serialization and deserialization.
- Returns:
- This JsonbConfig instance.
 
 - 
withAdapterspublic final JsonbConfig withAdapters(JsonbAdapter... adapters) Property used to specify custom mapping adapters. Configures value ofADAPTERSproperty. Calling withAdapters more than once will merge the adapters with previous value.- Parameters:
- adapters- Custom mapping adapters which affects serialization and deserialization.
- Returns:
- This JsonbConfig instance.
 
 - 
withSerializerspublic final JsonbConfig withSerializers(JsonbSerializer... serializers) Property used to specify custom serializers. Configures value ofSERIALIZERSproperty. Calling withSerializers more than once will merge the serializers with previous value.- Parameters:
- serializers- Custom serializers which affects serialization.
- Returns:
- This JsonbConfig instance.
 
 - 
withDeserializerspublic final JsonbConfig withDeserializers(JsonbDeserializer... deserializers) Property used to specify custom deserializers. Configures value ofDESERIALIZERSproperty. Calling withDeserializers more than once will merge the deserializers with previous value.- Parameters:
- deserializers- Custom deserializers which affects deserialization.
- Returns:
- This JsonbConfig instance.
 
 - 
withBinaryDataStrategypublic final JsonbConfig withBinaryDataStrategy(String binaryDataStrategy) Property used to specify custom binary data strategy. Configures value ofBINARY_DATA_STRATEGYproperty.- Parameters:
- binaryDataStrategy- Custom binary data strategy which affects serialization and deserialization.
- Returns:
- This JsonbConfig instance.
 
 - 
withDateFormatpublic final JsonbConfig withDateFormat(String dateFormat, Locale locale) Property used to specify custom date format. This format will be used by default for all date classes serialization and deserialization. Configures values ofDATE_FORMATandLOCALEproperties.- Parameters:
- dateFormat- Custom date format as specified in- DateTimeFormatter.
- locale- Locale, if null is specified- Locale.getDefault()will be used.
- Returns:
- This JsonbConfig instance.
 
 - 
withLocalepublic final JsonbConfig withLocale(Locale locale) Property used to specify custom locale. Configures value ofLOCALEproperty.- Parameters:
- locale- Locale, must not be null.
- Returns:
- This JsonbConfig instance.
 
 - 
withCreatorParametersRequiredpublic final JsonbConfig withCreatorParametersRequired(boolean requiredParameters) Property used to specify whether all creator parameters should be treated as required.
 Default value isfalse.- Parameters:
- requiredParameters- Whether creator parameters are required
- Returns:
- This JsonbConfig instance.
 
 
- 
 
-