Serializer options

Options of the json.Serializer class for controlling serialization behavior.

Table 1. Serializer options
Option Description Affects Default Example use
allowImplicitConversion This option modifies the behavior of JSON deserialization by allowing implicit type conversions when the JSON property specifies one type, but the values suggest another.
Typically, json.serializer implements strict schema validation during deserialization. If a JSON property is expected to be a certain type (for example, boolean), but the provided values are of a different type (for example strings), a deserialization error should occur.
  • Primitive Types: are not affected by allowImplicitConversion since Genero BDL allows implicit conversion for these types.
  • Arrays: When allowImplicitConversion is enabled, an array of INTEGER/NUMBER(DECIMAL), BOOLEAN, or STRING can accept values that are implicit conversions for those types, provided the values are valid for the intended type, even if represented incorrectly. For example, a boolean value is accepted with values represented as follows: 1, 0, true, false, "true", "false", or "1", "0". Note that allowImplicitConversion acts on the elements of a dictionary like an array.
  • Records/Objects: Currently, records or objects are not affected by the allowImplicitConversion option.
Important:

The option does not apply to simple-type oneOf JSON schemas because allowing implicit type conversion would compromise the integrity of schema validation, potentially leading to ambiguous or incorrect matches.

Deserialization (JSON to BDL) False

(implicit conversion is not allowed)

CALL json.Serializer.setOption("allowImplicitConversion",1). For an example, go to JSON to BDL deserialization option to allow implicit conversions
allowNullAsDefault Allow NULL values to be accepted during deserialization when the json_null="null" attribute is not explicitly specified. Deserialization (JSON to BDL) False

(NULL values are not allowed)

CALL json.Serializer.setOption("allowNullAsDefault",1). For examples, go to JSON to BDL deserialization options to allow nulls
serializeNullAsDefault Allow NULL values to be accepted during serialization, even if constraints are set (for example, JSONRequired defined or json_null="null" not defined). Serialization (BDL to JSON) False

(NULL values are not allowed)

CALL json.Serializer.setOption("serializeNullAsDefault",1). For examples, go to BDL to JSON serialization options to allow nulls
json_null="null" Attribute required to deserialize JSON null values ​​into BDL variables, or to enable serialization (BDL to JSON) of null values. Both Serialization (BDL to JSON) and Deserialization (JSON to BDL) Not set For more information about managing null with the json_null attribute, go to NULLs and empty structures.