RXS_GetJsonString()
This subprocedure retrieves JSON composed by RXS_CreateJson() and the other JSON composition subprocedures.
Subprocedure Prototype
|
Returns the contents of the created JSON structure. |
|
RXS_CreateJsonDS_t data structure which controls how RXS_CreateJson() functions. |
Example Code
*--------------------------------------------------------------
* This example creates a simple JSON object, adds a string 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_ComposeJsonString( 'hello' : 'world' : RootDS );
JSON = RXS_GetJsonString( CreateJsonDS );
// JSON looks like:
//
// {"hello":"world"}
RXS_DestroyJson( CreateJsonDS );
*INLR = *ON;
/end-free
Data Structures
|
|
|
|
|
Internal use only |
|
|
|
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. Valid Values:
Default Value: |
|
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. Valid Values:
Default Value: |
|
Internal use only |
|
Specifies the CCSID of the data being passed into the JSON composition subprocedures. Default is job CCSID. Default Value: |
|
Specifies the CCSID that the JSON will be output as from RXS_GetJsonString(). Default is job CCSID. Default Value: |
|
Determines whether to trim leading and trailing spaces from each value passed to RXS_ComposeJsonString() (RXS_YES), or to leave all spaces in place (RXS_NO). Valid Values:
Default Value: |