/**
* \brief JSON : Simple Example
*
* This examples show how to create a JSON string in RPG.
*
*
*
* 4 entries are added to the JSON object.
*
* - Error - *on
* - ErrorId - 358
* - ErrorDesc - My custom error message.
* - ErrorTime - current time
*
*
* The JSON string will be generated from the created JSON object.
*
* \author Mihael Schmidt
* \date 19.04.2008
*/
H dftactgrp(*no) actgrp(*caller)
*---------------------------------------------------------------
* PEP
*---------------------------------------------------------------
D main PR extpgm('JSON01')
D main PI
*---------------------------------------------------------------
* Prototypen
*---------------------------------------------------------------
/include 'json/json_h.rpgle'
*---------------------------------------------------------------
* Variablen
*---------------------------------------------------------------
D jsonObj S *
D jsonString S 32000A
/free
jsonObj = json_create();
json_putBoolean(jsonObj : 'Error' : *on);
json_putInt(jsonObj : 'ErrorId' : 358);
json_putString(jsonObj : 'ErrorDesc' : 'My custom error message.');
json_putString(jsonObj : 'ErrorTime' : %char(%time : *HMS:));
jsonString = %str(json_toString(jsonObj));
dsply %subst(jsonString : 1 : 50);
dsply %subst(jsonString : 51 : 50);
json_dispose(jsonObj);
*inlr = *on;
return;
/end-free