your welcome.
The question in detail is how you want to send it to the unix server. As already mentioned you can use for example json_httpRequest() within noxDB to send it directly to the unix Server if he has a Webservice that retrieves that Json. Json is normally used within REST services. Therefore I ask.
On the other hand you can use IceBreak or the open Source Framework ILEASTIC to host your own RPG Webservices and the Unix Server can access that.
Markus A. Litters
Original Message:
Sent: Wed November 22, 2023 04:29 AM
From: Siva Prasad
Subject: How can I employ RPGLE to generate a JSON document in IFS
Hi Markus,
Thanks for the reply it would be helpful for me.
Q: do you really need the Json in IFS or what do you want to do with that Json?
A: Yes, we need the Json in IFS to send this to UNIX server.
I will give a try with your solution. If I need any help, I can write here or contact you.
Kindly Regards,
Siva
------------------------------
Siva Prasad
Original Message:
Sent: Wed November 22, 2023 01:24 AM
From: Markus Litters
Subject: How can I employ RPGLE to generate a JSON document in IFS
Hi there,
as already mentioned on April, 11th you should give the ILE Open Source Framework noxDB a try.
This is for free and open Source and you can do anything with Json and XML inside RPG/Cobol/C/C** on IBM I and it is faster than the IBM SQL functions and much more flexible (although the IBM functions get better of course).
Your problem looks like a typical CCSID Problem.
The other question is, do you really need the Json in IFS or what do you want to do with that Json?
With noxDB you can directly send it via the ILE function json_httpRequest() to another Service/Webserver.
Give it a try. If you need any help with it, you can write here or contact me.
Either way or the other I wish you good luck with your project.
Kind regards
Markus
------------------------------
Kind regards
Markus A. Litters
Original Message:
Sent: Tue November 21, 2023 07:35 AM
From: Siva Prasad
Subject: How can I employ RPGLE to generate a JSON document in IFS
Hi Satid,
As per the above example7, I have created the JSON file in IFS folder like below.
Unfortunately, I am getting the symbol '£' instead of '[' while using the JSON_ARRAYAGG function. Could you please help me out of this ASAP.
dcl-s OUTFILE sqltype(CLOB_FILE) CCSID(1208);
Clear OutFile;
Outfile_Name = '/home/json.json';
Outfile_NL = %len(%trimr(Outfile_Name));
Outfile_FO = SQFCRT;
Exec SQL
select json_object('CREDITS' value json_arrayagg(json_object(
'CUSID' value CUSNUM, 'FSTNAME' value trim(FNAME),
'DATE' value trim(DATE), 'LSTNAME' value trim(LNAME),
'CRDLMT' value trim(CREDLMT))))
into :OUTFILE from mftdrsp20.CREDITS;
Result:
{"CREDITS":£{"CUSID":"10091","FSTNAME":"WILLIAMSON","DATE":"20231120","LSTNAME":"KANE","CRDLMT":"990099"},{"CUSID":"10092","FSTNAME"
:"LEWIS","DATE":"20231025","LSTNAME":"JOHN","CRDLMT":"900099"},{"CUSID":"10093","FSTNAME":"DANIEL","DATE":"20231118","LSTNAME":"MICH
EL","CRDLMT":"990000"},{"CUSID":"10094","FSTNAME":"ANTONY","DATE":"20230925","LSTNAME":"MARK","CRDLMT":"800000"},{"CUSID":"10095","F
STNAME":"ANDRICK","DATE":"20231029","LSTNAME":"MARKFED","CRDLMT":"900000"},{"CUSID":"10096","FSTNAME":"SMITH","DATE":"20231111","LST
NAME":"STEVE","CRDLMT":"850000"},{"CUSID":"10097","FSTNAME":"BEJOS","DATE":"20231202","LSTNAME":"JEF","CRDLMT":"700000"},{"CUSID":"1
0098","FSTNAME":"THOMAS","DATE":"20231208","LSTNAME":"EVANS","CRDLMT":"790000"},{"CUSID":"10099","FSTNAME":"AURTHOR","DATE":"2023113
0","LSTNAME":"ADAMS","CRDLMT":"780000"},{"CUSID":"10100","FSTNAME":"BUTTLER","DATE":"20231025","LSTNAME":"JOE","CRDLMT":"850000"}]}
------------------------------
Siva Prasad
Original Message:
Sent: Mon April 10, 2023 08:07 PM
From: Satid Singkorapoom
Subject: How can I employ RPGLE to generate a JSON document in IFS
Dear Mohan
You should do a Google search with "ibm i json" and you will see many informationn on this. Search with IBM i (or AS/400) + json in Youtube produces quite a few videoes on this as well.
As for SQL JSON-XXXX functions, I checked in IBM i documentation web site and found that all these information started in IBM i 7.2. But you should try it in your system just in case you may be lucky and it does not take much effort to try. Here is one good article on JSON-XXX : DB2 for i SQL JSON_OBJECT Essential Cheat Sheet at https://blog.faq400.com/en/db2-for-i/db2-for-i-sql-json_object-essential-cheat-sheet-2/. Example no. 7 is what you should look at.
------------------------------
Education is not the learning of facts but the training of the mind to think. -- Albert Einstein.
------------------------------
Satid S.
Original Message:
Sent: Mon April 10, 2023 05:25 PM
From: Mohan Eashver
Subject: How can I employ RPGLE to generate a JSON document in IFS
Thank you Daniel. Which OS version is required for JSON_xxx functions ?
We are on 7.1 yet.
------------------------------
Mohan Eashver
Original Message:
Sent: Mon April 10, 2023 04:47 PM
From: Daniel Gross
Subject: How can I employ RPGLE to generate a JSON document in IFS
Hi,
IMHO the easiest way to generate JSON is using embedded SQL and the JSON_xxx functions. Then write it out with IFS_WRITE.
HTH
------------------------------
Daniel Gross
Original Message:
Sent: Mon April 10, 2023 07:20 AM
From: Mohan Eashver
Subject: How can I employ RPGLE to generate a JSON document in IFS
Hello All,
Good Morning to you. how are you?
Do you simply suggest I write each row to a PF with all the delimiters & then convert PF to IFS thru Copy To Import File (CPYTOIMPF) ?
Or will you please share with me anything that you may have used in past to generate a JSON document in IFS thru RPG.
------------------------------
Mohan Eashver
------------------------------