× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Thanks. To be honest, I am trying multiple ways of handling and generating JSON to determine a preference. I've also tried using the other more manual method in YAJL, as well as, JSON_OBJECT, etc SQL functions. I'll look for examples of CGIDEV2 also.

-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Nathan Andelin
Sent: Thursday, February 13, 2020 10:58 AM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: JSON, DATA-GEN, YAJLDTAGEN, and Null

Stephen,

My suggestion is more a matter of preference, which understandably may vary from person to person or shop to shop. You evidently have a preference for DATA-GEN and YAJLDTAGEN.

When generating formatted streams (eg. JSON and XML), some of us prefer using a template API like the one in CGIDEV2 as opposed to DATA-GEN and/or a parser. With templates, you get to precisely determine the format and content of your output, including indentation or whatever. The API wouldn't have any problem placing 'null' or '' in an output stream.



On Thu, Feb 13, 2020 at 8:38 AM Stephen Piland < Stephen@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

Scott.. I guess if I really, really wanted to have YAJLDTAGEN 'fix'
this problem for me, I could maybe change to look for some reserved word (ex.
*NULL). Like when it returns from yajl_gen_string In the scalarValue
procedure. Just a thought. I may play around some.

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

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

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.