Page 1 of 1

Data Structure question in receiving json message using YAJLINTO

Posted: Fri Dec 30, 2022 5:18 pm
by Paul C
Hi:

I am trying to construct the data structure, output, to receive the json format you see below at the bottom using
DATA-INTO output %DATA(REPLY) %PARSER('YAJLINTO'); and it is not working.

what am I doing wrong here with the data structure?

Thanks
Paul

//Output Response Structure
dcl-ds output QUALIFIED;
dcl-ds result DIM(1);
Import_Result CHAR(10);
Request_Type CHAR(30);
Response CHAR(30);
end-ds;
end-ds;
======================================================
{
"result":[
{
"Import Result":"Success",
"Request Type":"Inbound Order",
"Response":"Open"
}
]
}

Re: Data Structure question in receiving json message using YAJLINTO

Posted: Fri Dec 30, 2022 10:45 pm
by Scott Klement
RPG defaults to expecting the JSON variable names to be in all-lowercase. Since yours contain uppercase, they won't match the RPG variable names... it's a poor default, in my opinion, but... that's what IBM decided to do.

Change your statement to use case=convert (I recommend always using this unless you have a good reason not to) and it should work fine.

Code: Select all

DATA-INTO output %DATA(REPLY:'case=convert') %PARSER('YAJLINTO');