.... I am starting to remember...
when I had a JSON string, that started with a JSON array ('[')... I
needed to "name it".

I have code that:
: dataSize
: %paddr('INCOMING')
: 'application/json' );

http_xlate(retlen: retdata: TO_EBCDIC); // we need to add a json
object over the array called "programs"...
retdata = '{"programs": ' + %trim(retdata) + '}' ;

// load the text into a DocNode object.

docNode =

yajl_buf_load_tree( %addr(retdata)

: %size(retdata)

: errMsg);

even though the JSON array would pass a validator, it wasn't working with

On Tue, Sep 5, 2017 at 10:28 AM, Pete Helgren <pete@xxxxxxxxxx> wrote:

I highly recommend that you copy and paste the whole *complete* string
into jsonlint.com and make sure that it is valid. Brad's recommendation
to dump it into a file is a good one.

(sorry if you already validated the JSON...I haven't followed the entire

Pete Helgren
GIAC Secure Software Programmer-Java
Twitter - Sys_i_Geek IBM_i_Geek

On 9/4/2017 7:29 PM, Booth Martin wrote:

I've read through Scott's material several times. Used his code. Clearly
I have missed something.

Currently this code:

MyIFSFile_Name = wURI;
MyIFSFile_NL = %Len(%trim(MyIFSFile_Name));

Exec SQL Set :MyText = Substr(:MyIFSFile, 1, 32000);
wLength = %len(MyText);

gives me:

1 '[{"name":"George Washington", "life":"1732-1799", "term":"17'
61 '89-04-30 to 1797-03-04", "party":"No Party"},{"name":"John A'
121 'dams", "life":"1735-1826", "term":"1797-03-04 to 1801-03-04"'
181 ', "party":"Federalist"},{"name":"Thomas Jefferson", "life":"'
241 '1743-1826", "term":"1801-03-04 to 1809-03-04", "party":"Demo'
301 'cratic-Republican"},{"name":"James Madison", "life":"1751-18'
361 '36", "term":"1809-03-04 to 1817-03-04", "party":"Democratic-'
421 'Republican"},{"name":"James Monroe", "life":"1758-1831", "te'
481 'rm":"1817-03-04 to 1825-03-04", "party":"Democratic-Republic'
541 'an"},{"name":"John Quincy Adams", "life":"1767-1848", "term"'
601 ':"1825-03-04 to 1829-03-04", "party":"Democratic-Republican"'
661 '},{"name":"Andrew Jackson", "life":"1767-1845", "term":"1829'
721 '-03-04 to 1837-03-04", "party":"Democratic"},{"name":"Martin'
781 ' Van Buren", "life":"1782-1862", "term":"1837-03-04 to 1841-'
841 '04-04", "party":"Democratic"},{"name":"William Henry Harriso'
901 'n", "life":"1773-1841", "term":"1841-03-04 to 1841-04-04", "'
961 'party":"Whig"},{"name":"John Tyler", "life":"1790-1862", "te'
1021 'rm":'

And then this line:

docnode = yajl_buf_load_tree(%addr(MyText): wLength: errMsg );

gets :

EVAL errMsg
1 'lexical error: invalid char in json text. '

On 9/2/2017 8:21 AM, Bradley Stone wrote:

There is no node named success in your JSON. That's why node is null.

Instead, you have an array of objects with name, life, term and party.
need to process through that array and for each object individually.

Processing arrays with YAJL is easy, and I think Jon already posted an
example of how to handle that. It should be in the archives or an older

Here's a great PDF from Scott that maybe you should spend some time on to
understand what JSON is, how it works, and how to use YAJL with it:


Bradley V. Stone
MAILTOOL Benefit #11 <https://www.bvstools.com/mailtool.html>: Save
- Save emails that are sent out at a global, user or individual email

This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related

Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2020 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].