Scott can correct me if I'm wrong... but YAJLINTO used with DATA-INTO can deal with null values.
I think what he's saying below applies to generating/creating JSON.
-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxxxxxxxx] On Behalf Of Stephen Piland
Sent: Monday, February 17, 2020 1:48 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: RE: JSON, DATA-GEN, YAJLDTAGEN, and Null
Boy.. This really sucks. I was able to use Scott's super helpful utility YAJLGEN that reads thru the JSON and creates the entire RPG source code to decode that JSON. All of the DCL-DS, etc that go many levels deep with the DATA INTO code too. It works great. Then you compile and go to try and use it, and because of this limitation imposed (or miss) by IBM, once it hits the 1st element's value that is NULL, you are dead in the water. I would have been able to save a week of work, but alas...
-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Scott Klement
Sent: Wednesday, February 12, 2020 5:01 PM
To: rpg400-l@xxxxxxxxxxxxxxxxxx
Subject: Re: JSON, DATA-GEN, YAJLDTAGEN, and Null
Hi Stephen,
Currently, it's not possible to generate a null value. DATA-INTO and DATA-GEN do not support null indicators (NULLIND/%NULLIND), so there's no way to pass a null value from RPG to the DATA-GEN generator program.
Sorry.
-SK
On 2/12/2020 4:32 PM, Stephen Piland wrote:
I'm attempting to generate a JSON using DATA-GEN opcode and YAJLs YAJLDTAGEN. It is working great and I'm liking it a lot. I haven't been able to figure out how to set a value to NULL ("LocationId":null).
In the mainline, I'm setting the null indicator on the field in the DS (%nullind(jsonDoc.data(x).LocationId) when necessary. I do have the nullind on the field in the data structure that I indicate in DATA-GEN and thought that might do it (see below). Any thoughts?
I'll debug YAJLDTAGEN next.
dcl-ds jsonDoc qualified;
num_data int(10) inz(0);
dcl-ds data dim(100);
LocationId varchar(4) inz(' ') nullind;
ItemId varchar(12) inz(' ');
Price packed(9:3) inz(0);
End-ds;
End-ds;
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
https://amazon.midrange.com
As an Amazon Associate we earn from qualifying purchases.