Null and empty value handling in json.Serializer and util.JSON
This topic compares how json.Serializer and util.JSON
handle null and empty values during JSON serialization and deserialization.
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.
| 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 |
|
|
NULL |
{} | OK | OK |
|
|
NULL |
[] | OK | OK |
1. Requires json_null attribute or serializeNullAsDefault
| 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 |
|
|
null |
- | ERROR 2 | OK |
|
|
null |
- | ERROR 2 | OK |
2. Requires json_null attribute or allowNullAsDefault.