Progress


 

2020/02/24
Numeric zero key not working SACASCR1 & SACBEER1

2020/02/07
Added File/Table SACBEEP. 
Now to complete my CRUD

2020/02/06
Removed four unnecessary lines off SACASCR1

2020/01/31
Copying an exiting working program and changing it to another file takes 10 lines of code to change and an additional 3 lines per field on the file to be used. (Updated 2020/02/07)


2020/01/24
Please could someone point me to open source RPG using YAJL consuming JSON on a simple file with GET, PUT, POST and DELETE. 

2020/01/27

2020/01/20
Thank you all for your assistance, you know who you are.
I have completed the JSON YAJL provider REST API (GET) in Totally/Fully Free RPG, comments and corrections are welcome.
This is open source, the data is also provided for the file/table SACADCP

Please could you comment on my blog  https://ibmrestapi.blogspot.com as this is part of my SEO experiment.

13 comments:

  1. ...I'm curious as to why you'd use YAJL instead of embedded SQL to create/consume JSON in RPG, which seems to me to be a better option?

    Tim Fathers

    ReplyDelete
    Replies
    1. Hello Tim.

      Thank you, please could you point or supply me sample code.

      Delete
    2. Personally, I tried out the SQL functions when they were first released. I found them counter-intuitive, as well as clunky and difficult to use.

      Justin Taylor

      Delete
    3. Man, you and Jon P! :) If those are anything like the XML SQL functions - at least for consuming content - I found those very manageable. I haven't spent any time with creating XML, though, so can't speak to any similarities with the JSON stuff.

      I went to SQL for consuming XML, because it was more flexible, and at 7.1, at least, was more forgiving about weird UTF-8 byte sequences, such as emojis. Neither XML-INTO or XML-SAX handled that at 7.1, and we had to make stuff work!

      For consuming content, I recommend Birgitta's presentations at COMMON, or maybe they're available elsewhere.

      Regards
      Vernon Hamberg

      Delete
    4. While it's true there's some overhead starting the JVM, which will make it expensive for one off requests, it's not significant if you are making multiple requests from the same job. On our production machine it takes between 5 and 10 seconds for the first request to happen, after that, round trip request times are in the hundreds of milliseconds, almost all of which will likely be the network and transport cost. Even if Java did perform worse than native RPG (which might be open to debate, but is probably true) then the difference would be marginal when compared to the comms overhead. The missing error information is probably my biggest grievance with the SQL web functions, there was a request open to have this added I think but it's never been done to my knowledge (but I'm stuck on 7.1 for much of my production work so it might be there now).

      For the manipulation of JSON objects in SQL Java is not used so there's no appreciable performance penalty, I see no reason not to use them even if you use another method of sending the request itself.

      In any case, ordinary SOAP/JSON web service requests can easily be done in just few lines of code without any third party dependencies. It's also much faster to develop them IME because you can run the SQL statements directly in the UI and see the immediate results, without having to compile, run and debug an RPG program each time you make a change. Once working, the SQL code can simply be pasted, as is, into a program if required.

      Tim Fathers

      Delete
    5. Hello Tim.

      Thank you once again, my challenge has been to find open code that I can place in debug.

      Maybe I could ask you to do a GET consumer API in SQL using the file on my web page https://ibmrestapi.blogspot.com/p/totallyfully-free-rpg.html.
      I could host your open code on one of my pages, then there would be working code to cut, paste, compile and run to compare, evaluate, and demonstrate.

      All of the code I have found for this effort was not consolidated and was tutorials to illustrate functionality, I tried to make it modular all inclusive.

      Delete
    6. I got it working, but it wasn't worth the effort required.
      "I can't remember the last time I wrote a program that used native I/O instead of embedded SQL but it was years ago."

      `You should not have a favorite tool. To be overly familiar with any one tool is as serious a fault of not knowing it sufficiently well.`

      Justin Taylor

      Delete
    7. Hi Esteban,

      Check if you can find me on Skype. I'll post a short PGM to get you going.

      Regards,

      Toni Schaake.

      Delete
    8. Thank you Toni, I sent you an email.

      Delete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. I'm assuming by "parse" you mean "construct" right? In any case why bother with a third party library, why not just use SQL?

    For single values just use:
    exec sql set :myField = coalesce(json_value(JSON_OBJECT, '$.error_message' returning varchar(256)), '');

    For multiple values use:
    select ... from json_table(JSON_OBJECT, '$.', ...);

    ..an example of which can be found here https://github.com/fathert/json-rpg-example/blob/master/json.sqlrpgle

    Tim.

    ReplyDelete
  4. Esteban,

    Try docNode = yajl_buf_load_tree(%addr(RdiRec) : RdiRecLen : errMsg); from YAJL

    I use in in 100's of programs.

    The sql JSON is Java based and I have find more issues with java on the iseries then Scotts programs.
    also Scott give better support.. __


    Thanks
    John Slanina

    ReplyDelete