|
wrote:
could it be...
you have a json object (the square brackets at the beginning and the
end...)
what if you remove those, and start with the curly bracket, and end with a
curly bracket....
On Mon, Sep 4, 2017 at 7:29 PM, 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));
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%20J
SON%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.
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
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 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].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.