RXS_ComposeJsonNull()
This subprocedure is used to add a JSON null element to a parent JSON Object or Array.
Subprocedure Prototype
|
|
|
Name to assign to JSON null data element. If being added to an array, the value of this parameter should be *OMIT. |
|
RXS_JsonStructureDS_t data structure containing a parent JSON Object or Json Array. |
Example Code
*--------------------------------------------------------------
* This example creates a simple JSON object, adds a null data
* field to it, retrieves the created JSON, and then calls
* RXS_DestroyJson() to clean up.
*--------------------------------------------------------------
H DFTACTGRP(*NO) BNDDIR('RXSBND') ACTGRP(*CALLER)
/copy QRPGLECPY,RXSCB
D JSON S Like(RXS_Var64Kv_t)
D CreateJsonDS DS LikeDS(RXS_CreateJsonDS_t)
D RootDS DS LikeDS(RXS_JsonStructureDS_t)
/free
RXS_ResetDS( CreateJsonDS : RXS_DS_TYPE_CREATEJSON );
RXS_ResetDS( RootDS : RXS_DS_TYPE_JSONSTRUCTURE );
CreateJsonDS.JsonStructureType = RXS_JSON_STRUCTURE_OBJECT;
RootDS = RXS_CreateJson( CreateJsonDS );
RXS_ComposeJsonNull( 'value' : RootDS );
JSON = RXS_GetJsonString( CreateJsonDS );
// JSON looks like:
//
// { "value": null }
RXS_DestroyJson( CreateJsonDS );
*INLR = *ON;
/end-free
*--------------------------------------------------------------
* This example creates a simple JSON array, adds 5 null data
* fields to it, retrieves the created JSON, and then calls
* RXS_DestroyJson() to clean up.
*--------------------------------------------------------------
H DFTACTGRP(*NO) BNDDIR('RXSBND') ACTGRP(*CALLER)
/copy QRPGLECPY,RXSCB
D JSON S Like(RXS_Var64Kv_t)
D CreateJsonDS DS LikeDS(RXS_CreateJsonDS_t)
D RootDS DS LikeDS(RXS_JsonStructureDS_t)
D i S 3U 0
/free
RXS_ResetDS( CreateJsonDS : RXS_DS_TYPE_CREATEJSON );
RXS_ResetDS( RootDS : RXS_DS_TYPE_JSONSTRUCTURE );
CreateJsonDS.JsonStructureType = RXS_JSON_STRUCTURE_ARRAY;
RootDS = RXS_CreateJson( CreateJsonDS );
for i = 1 to 5;
RXS_ComposeJsonNull( *OMIT : RootDS );
endfor;
JSON = RXS_GetJsonString( CreateJsonDS );
// JSON looks like:
//
// [null,null,null,null,null]
RXS_DestroyJson( CreateJsonDS );
*INLR = *ON;
/end-free
*--------------------------------------------------------------
* This example creates a simple JSON object, adds a null data
* field to it, retrieves the created JSON, and then calls
* RXS_DestroyJson() to clean up.
*--------------------------------------------------------------
H DFTACTGRP(*NO) BNDDIR('RXSBND') ACTGRP(*CALLER)
/define RXSV6R1
/copy QRPGLECPY,RXSCB
D JSON S Like(RXS_Var64Kv_t)
D CreateJsonDS DS LikeDS(RXS_CreateJsonDS_t)
D RootDS DS LikeDS(RXS_JsonStructureDS_t)
/free
RXS_ResetDS( CreateJsonDS : RXS_DS_TYPE_CREATEJSON );
RXS_ResetDS( RootDS : RXS_DS_TYPE_JSONSTRUCTURE );
CreateJsonDS.JsonStructureType = RXS_JSON_STRUCTURE_OBJECT;
RootDS = RXS_CreateJson( CreateJsonDS );
RXS_ComposeJsonNull( 'value' : RootDS );
JSON = RXS_GetJsonString( CreateJsonDS );
// JSON looks like:
//
// { "value": null }
RXS_DestroyJson( CreateJsonDS );
*INLR = *ON;
/end-free
*--------------------------------------------------------------
* This example creates a simple JSON array, adds 5 null data
* fields to it, retrieves the created JSON, and then calls
* RXS_DestroyJson() to clean up.
*--------------------------------------------------------------
H DFTACTGRP(*NO) BNDDIR('RXSBND') ACTGRP(*CALLER)
/define RXSV6R1
/copy QRPGLECPY,RXSCB
D JSON S Like(RXS_Var64Kv_t)
D CreateJsonDS DS LikeDS(RXS_CreateJsonDS_t)
D RootDS DS LikeDS(RXS_JsonStructureDS_t)
D i S 3U 0
/free
RXS_ResetDS( CreateJsonDS : RXS_DS_TYPE_CREATEJSON );
RXS_ResetDS( RootDS : RXS_DS_TYPE_JSONSTRUCTURE );
CreateJsonDS.JsonStructureType = RXS_JSON_STRUCTURE_ARRAY;
RootDS = RXS_CreateJson( CreateJsonDS );
for i = 1 to 5;
RXS_ComposeJsonNull( *OMIT : RootDS );
endfor;
RXS_GetJsonString( JSON : CreateJsonDS );
// JSON looks like:
//
// [null,null,null,null,null]
RXS_DestroyJson( CreateJsonDS );
*INLR = *ON;
/end-free
Data Structures
|
|
|
|
|
Internal use only |
|
|
|
Internal use only |
|
Internal use only |
|
Specifies the CCSID of the data being passed into the JSON composition subprocedures. Default is job CCSID. |
|
Specifies the CCSID that the JSON will be output as from RXS_GetJsonString(). Default is job CCSID. |