Basically.. I'm trying to build a larger, not well-formed JSON file. I say that because at the top level the 3rd party vendor wants multiple objects and they cannot, at this time accommodate a List. So what I'm doing is building 1 file with its 1 and only object at the top level, letting it write out to IFS, then appending any subsequent files to the first file I create.
Before writing out to IFS each individual file using yajl save buffer, I am retrieving the yajl buffer size and that is what I'm using as the file size.
All within a loop...
// done for every file generated
yajl_getBuf(jsonAddr:jsonSize);
yajl_saveBuf(jsonFilename:errMessage);
yajl_genClose();
// on 2nd file and on... Attempt to append json created in previous stmts to larger, master file
masterFd = open(%trim(masterFilename):O_WRONLY+O_CREAT+O_APPEND:1208);
callp write(masterFd:%addr(jsonFilename):jsonSize);
-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Scott Klement
Sent: Thursday, March 21, 2019 4:54 PM
To: rpg400-l@xxxxxxxxxxxxxxxxxx
Subject: Re: Append to IFS File
Hi Stephen,
There isn't a lot of information, here, but... from the symptoms, I'd guess that the length that you're passing to write() (SecondFileSize) is wrong. How are you reading the file and calculating the length?
-SK
On 3/20/19 12:21 PM, Stephen Piland wrote:
I believe I have a CCSID but I'm not sure...
I'm trying to add several smaller IFS files together into one. I build the first one, close it, and it looks good on IFS with CCSID 1208. Next, I build the 2nd IFS file and it looks good one IFS as CCSID 1208.
I try and open the first file (and masterFd=1) using...
masterFd = open(%trim(masterFilename):O_WRONLY+O_CREAT+O_APPEND:1208);
Next I try and write/append the 2nd IFS file but I get junk looking characters (see below), using...
callp write(masterFd:%addr(SecondFilename):SecondFileSize);
{"type":"string1","externalId":"FOOBAR1","description":"FOOBAR description1","description2":"FOOBAR description21","description3":"F
OOBAR description31"} Na a a a a m m K
Thoughts? Thanks!
--
Scott Klement
http://www.scottklement.com
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
https://amazon.midrange.com
As an Amazon Associate we earn from qualifying purchases.