Data Structure question in receiving json message using YAJLINTO

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.) http://www.scottklement.com/httpapi/
Post Reply
Paul C
Posts: 15
Joined: Fri Nov 25, 2022 6:38 am

Data Structure question in receiving json message using YAJLINTO

Post 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"
}
]
}
Scott Klement
Site Admin
Posts: 635
Joined: Sun Jul 04, 2021 5:12 am

Re: Data Structure question in receiving json message using YAJLINTO

Post 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'); 
Post Reply