Your JSON doc is a little wonky...

Thing to keep in mind is that the root of a JSON doc isn't named. "Data"
is actually the name of a json object in your document.

the ds you need is like so

dcl-ds doc;
dcl-ds data;
...
end-ds;
end-ds;

Data-into doc %Data(JsonString:'allowextra=yes') %PARSER('YAJLINTO');

HTH,
Charles


On Wed, Aug 4, 2021 at 3:07 PM Kathan Pandya <kathan.p@xxxxxxxxx> wrote:

Hi,

I am new to YAJL and using DATA-INTO. I have a simple json and I am trying
to read it using DATA-INTO and getting below error:
Cause . . . . . : While parsing a document for the DATA-INTO operation, the
parser found that the document does not correspond to RPG variable "data"
and the options do not allow for this. The reason code is 4. The exact
subfield for which the error was detected is "data.instruction2". The
options are "allowextra=yes". The document name is *N; *N indicates that
the
document is not an external file. The parser is 'YAJLINTO'. *N indicates
that the parser is a procedure pointer.

JSON -
{
"data": {
"instruction2": "FIRST SEAT",
"seat1l3": "2356",
"reset34": "Yes",
"temp": "-78",
"seat1l4": "326",
"seat2l3": "3265",
"instruction1": "** Daily Check Call **",
"seat2l4": "986",
"trl": "12345",
"seat2a70": "253",
"seat1a70": "895",
"eta": "2021-08-18T11:23:24-07:00",
"onsched": "Yes",
"hub": "896586",
"odo": "123658",
"reasonoffsched": "traffic"
},
"title": "Daily Check Call - 01"
}


RPG Declaration -

dcl-ds data qualified;
instruction2 char(50);
seat1l3 char(5);
reset34 char(1);
temp char(3);
seat1l4 char(5);
seat2l3 char(5);
instruction1 char(50);
seat2l4 char(5);
trl char(6);
seat2a70 char(5);
seat1a70 char(5);
eta char(26);
onsched char(1);
hub char(7);
odo char(11);
reasonoffsched char(70);
title char(50);
end-ds;

I am moving the data into a standalone character variable name JsonString
(using it below in Data-INTO)

Statement -
Data-into data %Data(JsonString:'allowextra=yes') %PARSER('YAJLINTO');


Please advise what am I doing wrong?
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
list
To post a message email: WEB400@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/web400.



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.