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));
MyIFSFile_FO = SQFRD;
Exec SQL Set :MyText = Substr(:MyIFSFile, 1, 32000);
wLength = %len(MyText);
gives me:
EVAL MyText
MYTEXT =
....5...10...15...20...25...30...35...40...45...50...55...60
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
ERRMSG =
....5...10...15...20...25...30...35...40...45...50...55...60
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. You
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
thread.
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:
http://www.scottklement.com/presentations/Working%20with%20JSON%20in%20RPG.pdf
Bradley V. Stone
www.bvstools.com
MAILTOOL Benefit #11 <https://www.bvstools.com/mailtool.html>: Save Emails
- Save emails that are sent out at a global, user or individual email
level.
As an Amazon Associate we earn from qualifying purchases.