Contents of smallexample.json
Code: Select all
[
{
"ShipmentID": 100
},
{
"ShipmentID": 200
}
]
Code: Select all
**FREE
ctl-opt dftactgrp(*no);
readTheJson();
*inlr = *on;
dcl-proc readTheJson;
Dcl-S num_jsonDoc int(10) inz(0); // Modified to add Dcl-S
dcl-ds jsonDoc qualified dim(3);
SHIPMENTID packed(3) inz(0);
end-ds;
Dcl-S Request Varchar(5000);
Dcl-S ifsPathName varchar(5000);
ifsPathName = '/temp/smallexample.json';
data-into jsonDoc %DATA( ifsPathname
: 'doc=file case=convert countprefix=num_')
%PARSER( 'YAJLINTO'
: '{ "document_name": "jsonDoc", +
"number_prefix": "YAJL_" }');
DATA-GEN jsonDoc %Data( Request : 'countprefix=num_ trim=all' )
%Gen( 'YAJLDTAGEN');
Return;
end-proc;
because it is not part of the data structure.
Note: I used YAGLGEN to create this program(except that I added the data-gen to demonstrate the result.
YAJLGEN created the num_jsonDoc on a line without the Dcl-S, I added that to get it to compile
In this case I want to have up to a dim of 3 of the json objects contained within the unnamed array
The DATA-GEN creates three instead of two objects because I don't know where to put the num_jsonDoc element
within the data structure.
Code: Select all
[{"SHIPMENTID":100},{"SHIPMENTID":200},{"SHIPMENTID":0}]
p.s. it looks like the yajl version is from Aug 2020. Not sure how to find the version number