YAJLDTAGEN and null

Discussions relating to the ScottKlement.com port of the open source YAJL JSON Reader/Generator. This includes the YAJL tool as well as the YAJLR4, YAJLGEN, YAJLINTO and YAJLDTAGEN add-ons from ScottKlement.com. http://www.scottklement.com/yajl/
Post Reply
mkhowe
Posts: 2
Joined: Thu Jan 02, 2025 1:48 pm

YAJLDTAGEN and null

Post by mkhowe »

I have a large data structure defined for building JSON and am using YAJLDTAGEN, and am running at V7R4. Some fields may not always have values and I'd like to be able to pass them as null. I can see where I can use ALWNULL(*USRCTL) and null indicators but I have to define the null indicator in the ds. Is there a capability with YAJLDTAGEN to not try and include those null indicator fields in the ds as part of the JSON? Similar to the countprefix?

Thank you for any assistance you can provide!
Scott Klement
Site Admin
Posts: 872
Joined: Sun Jul 04, 2021 5:12 am

Re: YAJLDTAGEN and null

Post by Scott Klement »

The DATA-GEN opcode in RPG does not support null indicators and doesn't have a way to indicate that a field is null. This makes it hard to do this within DATA-GEN.

It should theoretically be possible to do it with a prefix field as you suggest, but since RPG doesn't know about this field, it would be limited by comparison to other prefix fields, for example it would probably always have to be the field that immediately precedes the one it conditions. It would be complicated, but possible, to add it to YAJLDTAGEN if you accept those limitations. It would work much better if IBM added it to the DATA-GEN opcode.

Currently, it does not exist.

You can, of course, generate nulls quite easily using the YAJL subprocedures instead of DATA-GEN.
mkhowe
Posts: 2
Joined: Thu Jan 02, 2025 1:48 pm

Re: YAJLDTAGEN and null

Post by mkhowe »

Ok, I will check out the subprocedures.

Thank you
Post Reply