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



Interestingly enough. It seemed to work. Good idea!

-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Greg Wilburn
Sent: Wednesday, February 19, 2020 1:08 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: RE: JSON, DATA-GEN, YAJLDTAGEN, and Null

What happens if you set your YAJLOPTS to {"value_null":"0"}

Just curious to see if you still get the error.


-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxxxxxxxx] On Behalf Of Stephen Piland
Sent: Wednesday, February 19, 2020 1:54 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: RE: JSON, DATA-GEN, YAJLDTAGEN, and Null

Knowing I probably could set all of the numeric fields in the massive dcl-ds to character and test for it being numeric vs. null, I was hoping to avoid that. If I have to go that route, I probably would veer away from DATA-INTO.
However, based on the trace info below, it does seem to return nothing which seems correct for the YAJLOPTS value passed it. I am initializing this field/element to 0 when declared but also clearing it before executing DATA-INTO. The error message details and the data from the JSON are included below.

Any thoughts?

RPG Code
-------------
Inside dcl-ds several levels deep... FOLLOWONPROCESSEDAMOUNT packed(4: 2) inz(0);

dcl-c RPGOPTS const('doc=file case=convert countprefix=num_ allowextra=yes allowmissing=yes'); dcl-c YAJLOPTS const('{"value_null":""}');
clear jsonDoc; // clear out entire message before trying to data-info
data-into jsonDoc %DATA( ifsPathname : RPGOPTS) %PARSER( 'YAJLINTO' : YAJLOPTS);


Data in JSON
-----------------
Paymenttransaction(1)... "FollowOnProcessedAmount": 82.32, Paymenttransaction(2)... "FollowOnProcessedAmount": null,


Error Message Info
-------------------------
RNX0356 / The document for the DATA-INTO operation does not match the RPG variable; reason code 8.

Reason Code 8... The document contains data that cannot be successfully assigned to the RPG variable. The RPG status code associated with the failure is 105.

Erroring on... jsondoc.data.payment(1).paymentmethod(1).paymenttransaction(2).followonprocessedamount


Trace Info
-------------
ReportName: 'FollowOnProcessedAmount'
ReportValue: ''
Early return due to DATA-INTO processing error



-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Greg Wilburn
Sent: Monday, February 17, 2020 2:15 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: RE: JSON, DATA-GEN, YAJLDTAGEN, and Null

No... I believe it is returning nothing (there is no space between the double quotes). If you initialize the variables in your DS you should be fine.

JSON is a string... so everything is character-based.

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxxxxxxxx] On Behalf Of Stephen Piland
Sent: Monday, February 17, 2020 2:39 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: RE: JSON, DATA-GEN, YAJLDTAGEN, and Null

Based on this, null will be returned as blanks right? What if some elements that can have null assigned in the JSON are numeric? So some are character and some are numeric?

Thanks.

-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Greg Wilburn
Sent: Monday, February 17, 2020 1:04 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: RE: JSON, DATA-GEN, YAJLDTAGEN, and Null

Data-Into Orders %data(inStmf:RPGOPTS) %parser('YAJLINTO':YAJLOPTS);

Where:
dcl-c RPGOPTS const('doc=file case=convert allowextra=yes countprefix=count_');
dcl-c YAJLOPTS const('{ "value_null": "" }');

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxxxxxxxx] On Behalf Of Stephen Piland
Sent: Monday, February 17, 2020 1:48 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: RE: JSON, DATA-GEN, YAJLDTAGEN, and Null

Boy.. This really sucks. I was able to use Scott's super helpful utility YAJLGEN that reads thru the JSON and creates the entire RPG source code to decode that JSON. All of the DCL-DS, etc that go many levels deep with the DATA INTO code too. It works great. Then you compile and go to try and use it, and because of this limitation imposed (or miss) by IBM, once it hits the 1st element's value that is NULL, you are dead in the water. I would have been able to save a week of work, but alas...


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