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



Off the top of my head the only thing I can think of is that datasubf _might_ handle it. It is a similar situation to and XML element with both data and attributes. You'd still need a count or allowmissing.

I was going to try it for you but you haven't given enough of the JSON or me to be able to produce a valid JSON file that demonstrates your code.

You have validated the JSON right?


Jon

On Jan 6, 2021, at 3:00 PM, Greg Wilburn <gwilburn@xxxxxxxxxxxxxxxxxxxxxxx> wrote:

I'm consuming a relatively new web service... just wondering if the error I'm getting is due to my poor coding, or their poor implementation.


Message . . . . : The document for the DATA-INTO operation does not match
the RPG variable; reason code 4.
The exact subfield ..
json.response(1).repgroupretailermanufacturers.accountnumber

UGGHHH...

My DS looks like this...

...more above
num_repgroupretailermanufacturers uns(5) inz(0);
dcl-ds repgroupretailermanufacturers;
accountnumber varchar(10) inz(''); // This is our Customer Number
// minimumorderamount varchar(1) inz('');
// minimumreorderamount varchar(1) inz('');
// shipToAccountnumber varchar(1) inz('');
end-ds;
...more below

dcl-c RPGOPTS const('doc=file case=convert allowextra=yes countprefix=num_');
dcl-c YAJLOPTS const('{ "value_null": "", "document_name": "json"}');

monitor;
Data-Into json %data(inStmf:RPGOPTS) %parser('YAJLINTO':YAJLOPTS);
on-error;
ouErrors = 1;
return;
endmon;

The JSON array causing the error normally looks like this:

"repGroupRetailerManufacturers": {
"accountNumber": "10434741",
"minimumOrderAmount": 250,
"minimumReOrderAmount": 250,
"shipToAccountNumber": null
},

However, this document contains:

"repGroupRetailerManufacturers": null,


Short of having a NUM_ variable in front of EVERY element, is my only option to do allowmissing=yes??
(I can "feel" Jon Paris leaning over my shoulder while I code) LOL


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