Re: Options for YAJLINTO to handle a null array

Daniel Gross <[email protected]> Tue, 24 Feb 2026 22:57:42 +0100
Newsgroups gmane.comp.lang.as400.rpg
Message-ID <[email protected]>
Hi Greg,

if you want, send me some example of your JSON and what you need to extract - the  I can prepare you an example for the data you need. 

Once you have an understanding of the syntax of JSON_TABLE it's quite easy. 

Regards,
Daniel


> Am 24.02.2026 um 22:40 schrieb Greg Wilburn <[email protected]>:
> Daniel,
> 
> Thanks.  I would like to learn it - have a new tool in the toolbox.  I just really struggle with the syntax of SQL - I find it difficult to read/follow.  I use it quite a bit for I/O (not always) and other things.  In fact, in this very project I'm using the table function IFS_READ to read text file template for my request - it's easier to change the file on the IFS than to recompile a program.
> 
> I worked this one out by using a combination of two data structures, count prefix, and nested Data-Into operation.  Seems to be working pretty slick and not many lines of code (11 lines with two small DS).
> 
> Thanks again to all who replied.  You all are great!
> 
> Greg
> 
> -----Original Message-----
> From: RPG400-L <[email protected]> On Behalf Of Daniel Gross
> Sent: Tuesday, February 24, 2026 10:29 AM
> To: [email protected]
> Subject: Re: Options for YAJLINTO to handle a null array
> 
> Hi Greg,
> 
> I know, I sound like a broken record - and I also know, that many RPG programmers like YAJLINTO to handle their JSON needs - but in the end, using SQL and JSON_TABLE is superior in handling NULL values, empty arrays and all the other edge cases in JSON.
> 
> And it's a simple 1-time learning curve to master - but as you can do that interactively, with "Run SQL Scripts" or even STRSQL, you reach your goal quite fast.
> 
> If you need any support with that, let me know it.
> 
> HTH and kind regards,
> Daniel
> 
> 
>> Am 24.02.2026 um 16:05 schrieb Greg Wilburn <[email protected]>:
>> 
>> Thank you!
>> 
>> I've tried various iterations of using the countprefix option.  I was just surprised to see the count of the errors array at "1" when it's received as "null".  In this case, I supposed "errors" is present, but the underlying "field" and "messages" are not?
>> 
>> I'm considering creating separate DS for each situation and placing them in nested monitor statements... Or is that "bad form"?
>> I would expect to receive a "successful" post of the shipment most of the time.
>> 
>> Greg
>> 
>> 
>> 
>> -----Original Message-----
>> From: RPG400-L <[email protected]> On Behalf Of Martijn van Breden
>> Sent: Tuesday, February 24, 2026 4:38 AM
>> To: RPG programming on IBM i <[email protected]>
>> Subject: Re: Options for YAJLINTO to handle a null array
>> 
>> Hello Greg
>> 
>> We ran into this a while ago and experimented with null indicators and so on but that won't work.
>> You can use the countprefix keyword instead to handle this. It will be zero with an empty or null array.
>> 
>> 
>> Kind regards,
>> 
>> Martijn van Breden
>> 
>> lead software architect
>> 
>> 
>> 
>> --
>> This is the RPG programming on IBM i (RPG400-L) mailing list
>> To post a message email: [email protected]
>> To subscribe, unsubscribe, or change list options,
>> visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
>> or email: [email protected]
>> Before posting, please take a moment to review the archives
>> at https://archive.midrange.com/rpg400-l.
>> 
>> Please contact [email protected] for any subscription related questions.
>> 
>> Greg Wilburn
>> Director of IT
>> 301.895.3792 ext. 1231
>> --
>> This is the RPG programming on IBM i (RPG400-L) mailing list
>> To post a message email: [email protected]
>> To subscribe, unsubscribe, or change list options,
>> visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
>> or email: [email protected]
>> Before posting, please take a moment to review the archives
>> at https://archive.midrange.com/rpg400-l.
>> 
>> Please contact [email protected] for any subscription related questions.
> --
> This is the RPG programming on IBM i (RPG400-L) mailing list
> To post a message email: [email protected]
> To subscribe, unsubscribe, or change list options,
> visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
> or email: [email protected]
> Before posting, please take a moment to review the archives
> at https://archive.midrange.com/rpg400-l.
> 
> Please contact [email protected] for any subscription related questions.
> 
> Greg Wilburn
> Director of IT
> 301.895.3792 ext. 1231
> --
> This is the RPG programming on IBM i (RPG400-L) mailing list
> To post a message email: [email protected]
> To subscribe, unsubscribe, or change list options,
> visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
> or email: [email protected]
> Before posting, please take a moment to review the archives
> at https://archive.midrange.com/rpg400-l.
> 
> Please contact [email protected] for any subscription related questions.
-- 
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: [email protected]
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact [email protected] for any subscription related questions.