/** * \brief JSON : Nested Array Example * * This examples show how to create a JSON string in RPG * with multiple arrays. * * \author Mihael Schmidt * \date 08.05.2008 */ H dftactgrp(*no) actgrp(*caller) *--------------------------------------------------------------- * PEP *--------------------------------------------------------------- D main PR extpgm('JSON03') D main PI *--------------------------------------------------------------- * Prototypes *--------------------------------------------------------------- /include 'json/json_h.rpgle' *--------------------------------------------------------------- * Variablen *--------------------------------------------------------------- D jsonObj S * D jsonArray S * D jsonArray2 S * D jsonString S 32000A /free jsonObj = json_create(); jsonArray = jsona_create(); jsona_putInt(jsonArray : 1); jsona_putInt(jsonArray : 2); jsona_putInt(jsonArray : 4); jsona_putInt(jsonArray : 8); json_putArray(jsonObj : 'Power of 2' : jsonArray); jsonArray2 = jsona_create(); jsona_putInt(jsonArray2 : 1024); jsona_putInt(jsonArray2 : 2048); jsona_putInt(jsonArray2 : 4096); jsona_putArray(jsonArray : jsonArray2); jsonString = %str(json_toString(jsonObj)); dsply %subst(jsonString : 1 : 50); dsply %subst(jsonString : 51 : 50); json_dispose(jsonObj); *inlr = *on; return; /end-free