|
thank you all it's working now!!
I do a little different question - it might not be relevant to the group
here but still posting it if someone encountered it earlier:-
DS subfields "eta" , data below:-
"eta": "2021-08-18T11:23:24-07:00"
- is there a way i can break this sub-field into yyyy, mm, dd ? (three
different fields based on position?
I can do it by moving this DS_structure.ETA field into another DS and then
break it down but can I do it here only? so that i can avoid creating
multiple variables/DS.
dcl-ds json qualified;
dcl-ds data;
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);
end-ds;
title char(50);
end-ds;
Data-into JSON %Data(JsonString:'doc=string case=convert')
%PARSER('YAJLINTO');
On Wed, Aug 4, 2021 at 2:36 PM Jon Paris <jon.paris@xxxxxxxxxxxxxx> wrote:
As Charles indicted you are not mapping the json correctly.look
data is an element _within_ the target DS as is title. So it needs to
like this:do
dcl-ds parsedData qualified;
dcl-ds data;
instruction2 char(50);
...
end-ds;
title char(50);
end-ds;
Then your Data-Into becomes:
Data-into parsedData %Data(JsonString:'case=convert')
%PARSER('YAJL/YAJLINTO');
Because (unlike XML) json does not have a named outer element, DATA-INTO
will just accept the name of the DS you target as if it were the root
element name.
Notice also that (in this case) there is no need for allowextra BUT you
need some form of case= and since json can use non-RPG characters innames
using =convert is a good choice - although in this case case=any wouldhave
worked as there are no special characters in the names.wrote:
Jon Paris
On Aug 4, 2021, at 5:19 PM, Charles Wilt <charles.wilt@xxxxxxxxx>
"Data"
Your JSON doc is a little wonky...
Thing to keep in mind is that the root of a JSON doc isn't named.
wrote: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>
operation,trying
Hi,
I am new to YAJL and using DATA-INTO. I have a simple json and I am
to read it using DATA-INTO and getting below error:
Cause . . . . . : While parsing a document for the DATA-INTO
thethat
"data"parser found that the document does not correspond to RPG variable
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
indicatesthe
document is not an external file. The parser is 'YAJLINTO'. *N
mailingJsonStringthat 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
(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)
mailinglist--
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.
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400)
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.
--
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.
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 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.