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!
YAJLDTAGEN and null
-
- Site Admin
- Posts: 872
- Joined: Sun Jul 04, 2021 5:12 am
Re: YAJLDTAGEN and null
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.
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.
Re: YAJLDTAGEN and null
Ok, I will check out the subprocedures.
Thank you
Thank you