Hi Booth,

Looks like you're using an SQL LOB and then taking a substring of it. Sorry if you've previously explained this (I haven't followed the whole conversation) but why are you doing that? Seems like a very weird thing to do. How do you know that 32000 is the correct length for the substring, and won't chop off part of your document?

Also, the call to yajl_buf_load_tree seems wrong, you're specifying %addr(var) instead of %addr(var:*data). That will only work if the variable doesn't store other things besides data in it. Are you sure that's what you want to do?

Honestly, I'm finding this whole thread hard to follow, there's so much "noise" in it. So a full description that doesn't rely on reading other messages in this thread would help a lot :-)

-SK




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));
          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.



This thread ...

Follow-Ups:
Replies:

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].