Not sure if you are set on a DB2 file outputting JSON and then writing it out....I haven't played with JSON in that way. But I am using CGIDEV2 in a SQLRPGLE program and it simply outputs JSON as part of an HTML template where I iterate through the DB records, and use updhtmlvar to update each json value in the template and just write it out. You can see it in action here:
As an Amazon Associate we earn from qualifying purchases.
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.