JSONNULL attribute
The JSONNULL attribute indicates if an item should be generated as a JSON null during the invocation of JSONPUTVALUE or JSONPUTMEMBER.
When JSONNULL is specified on a scalar, the scalar is generated as "null" if the item is a string equal to the null string ('') or a number equal to 0.
When JSONNULL is specified on a structure, the structure is generated as "null" if all its leaf elements are null.
When JSONNULL is specified on an array, any null elements in the array are generated as "null". and if all elements in the array are null, then the entire array is generated as "null".
For example, given the following code:
dcl buffer char(4096);
dcl written fixed bin(31);
dcl elev(5) pic'99999V.99' static
init( 1200, 0, 11500, 0, 11750 ) jsonnull;
written = 0;
written = jsonputmember( addr(buffer), stg(buffer), elev );
The output buffer will contain:
"ELEV":["01200.00",null,"11500.00",null,"11750.00"]
If all the elements in the array were 0, then the output buffer will contain:
"ELEV":null
If JSONNULL and JSONOMIT are both specified for a field, then JSONOMIT takes precedence.
- Unions
- Unnamed elements
- Elements that use nonnative float (hex or dfp on Windows)