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



This is a good example of why I don't recommend using allowmissing=yes - you get less help when things go wrong. It is not needed here but having it prevented you from seeing an error message that hinted the way.

This what the DS should look like:

Dcl-ds items qualified;
num_items int(10); <<< This relates to the _following_ array.
dcl-ds items dim(99);
firstName char(50);
lastName char(50);
email char(100);
id char(64);
end-ds;
end-ds;

data-into items
%DATA( input
: 'case=any allowextra=yes countprefix=num_')
%PARSER('YAJL/YAJLINTO');

Note the array is not at the outer level. I kept the name items at the outer level but you could use any name.

As someone else noted you can use Scott's routine to generate a guestimate of the required DS from the json.

Jon Paris
Jon.Paris@xxxxxxxxxxxxxx



On Nov 19, 2024, at 12:04 PM, Jim Franz <franz9000@xxxxxxxxx> wrote:

I have data structure set up, and able to execute YAJLINTO, but no values
in DS and no errors.
V7R5

The json is here, have clipped out many other columns to make shorter (and
there may be 1 item or many but in this case json has 1 set of values)
{"items": [ {
"firstName":".",
"lastName":"CESAR GLASS AND CONSTRUCTION",
"email":"CGC78@xxxxxxxxxx",
"shippingAddress":
{
"countryDisplay":null,
"stateDisplay":null,
"line1":null,
"line2":null,
"city":null,
"country":null,
"state":null,
"zip":null
},
"paymentMethods":[],
"createdOn":"2024-11-17T19:08:30.601Z",
"modifiedOn":null,
"id":"97bb28db-a8f5-42a7-929b-b22b013b729d"
}
],
"total":1}

i'm sure my DS not right,( and left out of DS shippingAddress,
paymentMethods, and total as not needed in this pgm).. but perhaps that's
the issue of not defining the complex parts of this json?
I've searched archives, Scott's online docs and posts, but not found a
similar json example.
* define work fields
D xOut S 5000
* define data structure for json results


data-into items
%DATA(xOut
: 'case=any allowextra=yes allowmissing=yes countprefix=num_')
%PARSER('YAJLINTO');

degug shows only num_list has a value
ITEMS.NUM_LIST(1) = 1077952576 and same value in all 99 buckets of array

I do have several other YAJLINTO programs working ok with same vendor, but
this is first with an "items" json.

TIA
Jim Franz
--
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.



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.