Layer7 API Management

  • 1.  Perform JDBC query on JSON

    Posted Aug 23, 2017 01:22 AM

    I want to perform CRUD operation on JSON file as an input.

    As data structure we have JSON array with objects for each entry e.g. for roles:

    [

      {

                   "role_id":1,

                  "role_alias":"globaladmin",

                   "role_name":"Global Admin",

                   "role_desc":"descr of global admin "

      },

      {

                   "role_id":2,

                  "role_alias":"localadmin",

                   "role_name":"Local Admin",

                   "role_desc":"descr of local admin "

      } 

    ]

     

    I want to UPDATE the "roles" tables with above details so effected rows would be 2.

    Lets say, for role_id :1, i want to update role_name, similarly for role_id:2.

    Please provide inputs how i can iterate through json objects and update the database.

     

    Regards

    Vidhi Gupta



  • 2.  Re: Perform JDBC query on JSON

    Broadcom Employee
    Posted Aug 24, 2017 04:43 PM

    To clarify you want to take the above and make a custom table named role that gets updated with each of these subgroups?

    I can try to make a quick sample but not sure if I have your entire use case.



  • 3.  Re: Perform JDBC query on JSON
    Best Answer

    Broadcom Employee
    Posted Aug 25, 2017 08:37 AM
      |   view attached

    Here is a sample that will basically iterate through your message and treat individual records. 

    I hope it helps.

    ..

    Attachment(s)

    zip
    Jsoninterate.xml.zip   1 KB 1 version


  • 4.  Re: Perform JDBC query on JSON

    Broadcom Employee
    Posted Sep 04, 2017 08:59 PM

    Hello Charles,

    Good example.

    We can also loop the ${jsonRBAC.results} directly, it's already a multi-valued context variable after json path.

     

    Regards,

    Mark