RXS_DestroyJson()

This subprocedure is used to end JSON composition or parsing. It is important to call this subprocedure before your program ends, even if it is ending abnormally.

Subprocedure Prototype

D RXS_DestroyJson...
D                 PR                  Extproc('RXS_DestroyJson') Opdesc
 
D  pJsonDS                            Like(RXS_Var64K_t) Options(*Varsize)

RXS_CreateJsonDS_t data structure or RXS_ParseJsonDS_t data structure.

Example Code

*--------------------------------------------------------------
* This example creates a simple JSON object, adds a data field 
* to it, 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_ComposeJsonString( 'hello' : 'world' : RootDS );

   JSON = RXS_GetJsonString( CreateJsonDS );

   RXS_DestroyJson( CreateJsonDS );

   *INLR = *ON;
 /end-free
*--------------------------------------------------------------
* This example creates a simple JSON object, adds a data field 
* to it, 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_ComposeJsonString( 'hello' : 'world' : RootDS );

   RXS_GetJsonString( JSON : CreateJsonDS );

   RXS_DestroyJson( CreateJsonDS );

   *INLR = *ON;
 /end-free

Data Structures

D RXS_CreateJsonDS_t...
D                 DS                  Qualified Template Inz
 
D   ReturnedErrorInfo...
D                                     LikeDS(RXS_ReturnedErrorInfoDS_t) Inz
 
D   DataStructureType...
D                                5I 0 Inz(RXS_DS_TYPE_CREATEJSON)

Internal use only

D   OnErrorMessageType...
D                                5I 0
 
D   Prettify                      N   Inz(RXS_NO)

If set to RXS_YES, JSON retrieved with RXS_GetJsonString() will be formatted with whitespace to be "pretty" and more human readable. If set to RXS_NO, JSON will be returned in a compact form with as little whitespace as possible.

D   JsonStructureType...
D                                 N   Inz(RXS_JSON_STRUCTURE_OBJECT)

If set to RXS_JSON_STRUCTURE_OBJECT, the JSON document being created will begin with a root JSON object. If set to RXS_JSON_STRUCTURE_ARRAY, it will begin with a root JSON array.

D   JsonStructure@...
D                                 *   Inz(*Null)

Internal use only

D   InputCcsid...
D                               10I 0 Inz(RXS_CCSID_JOB)

Specifies the CCSID of the data being passed into the JSON composition subprocedures. Default is job CCSID.

D   OutputCcsid...
D                               10I 0 Inz(RXS_CCSID_JOB)

Specifies the CCSID that the JSON will be output as from RXS_GetJsonString(). Default is job CCSID.

D RXS_JsonStructureDS_t...
D                 DS                  Qualified Template Inz
 
D   ReturnedErrorInfo...
D                                     LikeDS(RXS_ReturnedErrorInfoDS_t) Inz
 
D   DataStructureType...
D                                5I 0 Inz(RXS_DS_TYPE_JSONSTRUCTURE)

Internal use only

D   OnErrorMessageType...
D                                5I 0
 
D   JsonStructureType...
D                                 N   Inz(RXS_JSON_STRUCTURE_OBJECT)

Internal use only

D   JsonStructure@...
D                                 *   Inz(*Null)

Internal use only

D   InputCcsid...
D                               10I 0 Inz(RXS_CCSID_JOB)

Specifies the CCSID of the data being passed into the JSON composition subprocedures. Default is job CCSID.

D   OutputCcsid...
D                               10I 0 Inz(RXS_CCSID_JOB)

Specifies the CCSID that the JSON will be output as from RXS_GetJsonString(). Default is job CCSID.