Handling null

This section focuses on the key differences in JSON serialization and deserialization implicit behaviors for handling null or empty values between json.Serializer and util.json.

For detailed comparisons and examples, refer to the tables below dedicated to null handling for both APIs.

For more information about managing null with the json_null attribute, go to NULLs and empty structures.

Table 1. Serialization BDL to JSON
Type BDL value JSON output json.Serializer util.json
BOOLEAN NULL null ERROR 1 OK
FGL-Integer/Number NULL null ERROR 1 OK
FGL-STRING NULL null ERROR 1 OK
DATE NULL null ERROR 1 OK
DATETIME NULL null ERROR 1 OK

FGL-Object

util.JSONObject

NULL {} OK OK

FGL-Array

util.JSONArray

NULL [] OK OK

1. Requires json_null="null" or serializeNullAsDefault

Table 2. Deserialization JSON to BDL
Type JSON input Result json.Serializer util.json
BOOLEAN null NULL ERROR 2 OK
FGL-Integer null NULL ERROR 2 OK
FGL-STRING null NULL ERROR 2 OK
DATE null NULL ERROR 2 OK
DATETIME null NULL ERROR 2 OK

FGL-Object

util.JSONObject

null - ERROR 2 OK

FGL-Array

util.JSONArray

null - ERROR 2 OK

2. Requires json_null="null" or allowNullAsDefault.