ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Use of JSon inside a webservice application

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Use of JSon inside a webservice application

    Hi,

    we have a lot of CGI that answer with json to our web platform.
    Until now we try to use always the json sql function to create the answer, but we have the need to add some information to the json that are not in a table but derived by run time process.

    How can we add some information inside the json taking it by a response of an rpg program?

    In some cases a create a function sql to wrap my rpg program and I put it in my sql statement. Do you have other solutions?

    Many thanks


  • #2
    It depends on what you need to add and where I guess. You could use the SQL JSON stuff and use user defined functions and similar to generate the non-table data.

    Personally I use DATA-GEN to generate JSON and would use SQL to populate the data structure(s) used by the generator. Another option would be to use the raw YAJL APIs to generate the JSON.

    Show us a sample of what you are trying to generate and we might be able to offer more concrete suggestions.

    Comment


    • #3
      @SQL Functions ... you always can include additional information by using host variables or using SQL global variables containing the additional information.
      ... and by using Common Table Expressions even complex JSON documents stay readable.
      In the first (few) CTE you put the information you need togehter and in the next CTEs you start generating your JSON document from the lowest level to the highest one until you finally return the complete JSON document within the final SELECT.

      Without exactly seeing what you need, we can only guess.

      Comment

      Working...
      X