Re: Options for YAJLINTO to handle a null array

Jon Paris <[email protected]> Tue, 24 Feb 2026 21:01:48 +0000
Newsgroups gmane.comp.lang.as400.rpg
Message-ID <[email protected]>
Don't forget that countprefix can also be used against an individual field - it is not array specific - so if the array count is 1 you can check the field count for zero.

Not saying _not_ to use SQL, but if you are not familiar with SQL's JSON processing, then this may help with your existing RPG.

 
Jon Paris
[email protected]



> On Feb 24, 2026, at 3:28 PM, Daniel Gross <[email protected]> wrote:
> 
> 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.
> 

-- 
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.