Page 1 of 1

Problem copying a node to a stream file

Posted: Tue Jun 14, 2022 12:51 pm
by imaxeman69
I'm using this code to copy the top node to a stream file:

Code: Select all

           if docNode <> *null;
             inboundFile = '/P44/Inbound/P44ShipmentUpdate_' +
                           %char(%date():*iso0) + '_' +
                           %char(%time():*hms0) + '.json';
             yajl_save_string_stmf(docNode:
                                   inboundFile:
                                   errMsg);
             if errMsg <> *blanks;
               EXEC SQL
                 INSERT INTO Wserlgfl
                 VALUES(CURRENT TIMESTAMP,
                        'Copy Error',
                        errMsg);
             endif;  
I'm not getting a stream file. errMsg is blank.
I know it's not null, because this code is working:

Code: Select all

             nodeq = YAJL_object_find(docNode: 'shipment');
             if nodeQ <> *null;
It's falling through the rest of the code.

Re: Problem copying a node to a stream file

Posted: Tue Jun 14, 2022 12:56 pm
by imaxeman69
Sorry, this is where docNode comes from:

Code: Select all

           docNode = yajl_stdin_load_tree(UTF8encoded : errMsg);


Re: Problem copying a node to a stream file

Posted: Wed Jun 15, 2022 11:44 am
by imaxeman69
Ok, I see that I can only write out string nodes. My SQL was wrong, which is why I wasn't getting anything in my error log.

So, Is there a way to capture the entire JSON string into a variable or a stream file?

Re: Problem copying a node to a stream file

Posted: Thu Jun 16, 2022 12:44 am
by Scott Klement
YAJL_stringify() will let you output everything at a given node to a variable.

Re: Problem copying a node to a stream file

Posted: Mon Jun 20, 2022 7:08 pm
by imaxeman69
Thanks, Scott.

Re: Problem copying a node to a stream file

Posted: Tue Jun 28, 2022 11:56 am
by imaxeman69
Getting this error: ERROR decoding EStdString

I pass the pointer to the doc node to another program. Then do the work to save the document node to the stream file and get this error.

Re: Problem copying a node to a stream file

Posted: Tue Jun 28, 2022 5:10 pm
by Scott Klement
I am not familiar with the message "ERROR decoding EStdString" -- I haven't seen that before. I searched the source code for YAJL, and nothing reports that error.

I did a Google, and the only matches I find are with the IBM i debugger -- perhaps this is coming from the debugger?

Re: Problem copying a node to a stream file

Posted: Wed Jun 29, 2022 3:19 pm
by imaxeman69
Same here. And, I was in debug when I saw that. I was looking at the second argument of the YAJL_STRINGIFY procedure.

Thanks,