JSON to BDL deserialization option to allow implicit conversions
To relax deserialization, you can set the allowImplicitConversion
option
to allow implicit data conversion.
By default, Genero Web Services deserialization will raise errors if the JSON content does not match the BDL variable receiving the data. For more information on implicit and explicit conversion of JSON to Genero BDL, go to Understanding implicit/explicit serialization.
In this example, you have a BDL variable that is defined as
follows:
PRIVATE TYPE TypedLists RECORD
ints DYNAMIC ARRAY OF INT,
strings DYNAMIC ARRAY OF STRING
END RECORD
The following JSON document will raise conversion errors by default because the "strings" array
does not contain valid string values. For example, it should be formatted as "
strings":
["1", "2"]
" to correspond with the expected data type. Here is the original
JSON:{
"ints": [1, 2],
"strings": [1, 2]
}
To avoid the conversion error, you can set the following option in your server module to allow
implicit type
conversion:
CALL json.Serializer.setOption( "allowImplicitConversion", 1 )
For more details, go to json.Serializer.setOption.