/**
* \brief JSON : Array Example
*
* This examples show how to create a JSON string in RPG.
*
*
*
* 4 entries are added to the JSON object. One entry has an array as value.
*
* - Error - *on
* - ErrorId - [ 358 , 712 , 121232 ],
* - ErrorDesc - My custom error message.
* - ErrorTime - current time
*
*
*
*
* The JSON string will be generated from the created JSON object.
*
* \author Mihael Schmidt
* \date 20.04.2008
*/
H dftactgrp(*no) actgrp(*caller)
*---------------------------------------------------------------
* PEP
*---------------------------------------------------------------
D main PR extpgm('JSON02')
D main PI
*---------------------------------------------------------------
* Prototypen
*---------------------------------------------------------------
/include 'json/json_h.rpgle'
*---------------------------------------------------------------
* Variablen
*---------------------------------------------------------------
D jsonObj S *
D jsonArray S *
D jsonString S 32000A
/free
jsonObj = json_create();
jsonArray = jsona_create();
jsona_putInt(jsonArray : 358);
jsona_putInt(jsonArray : 712);
jsona_putString(jsonArray : '121232');
json_putBoolean(jsonObj : 'Error' : *on);
json_putArray(jsonObj : 'ErrorId' : jsonArray);
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);
dsply %subst(jsonString : 101 : 50);
json_dispose(jsonObj);
*inlr = *on;
return;
/end-free