The JSON isn't terminated in 1021 there is someting missing since it must
end with }]

On Tue, Sep 5, 2017 at 2:29 AM, Booth Martin <booth@xxxxxxxxxxxx> 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 <>: 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,
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives

Please contact support@xxxxxxxxxxxx for any subscription related

Help support by shopping at with our affiliate

As an Amazon Associate we earn from qualifying purchases.

This thread ...


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

This mailing list archive is Copyright 1997-2021 by 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].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.