PL/I

PL/I

PL/I

 View Only
  • 1.  JSON Parser in PL/I

    Posted Mon July 24, 2023 02:32 PM

    Hi All,

    Is it possible to parse JSON data in PL/I? My requirement is to parse request JSON received through z/OS connect and use those key fields and values in constructing a WHERE clause dynamically for DB2 query in my program.

    eg:

     Request received:

     

    { {  EMP_ID:'abc',EMP_NAME:'abc',EMP_NO:'20',EMP_REG:[1,4,5,6],EMP_STATUS:'A'},
      {  EMP_ID:'xyz',EMP_NAME:'acd',EMP_NO:'10',EMP_REG:[9,10],EMP_STATUS:'A'},
          …
          ….
          … }

     

    Expected WHERE clause in program (after parsing and appending data wherever needed):

    SELECT COL1, COL2 

    FROM TABLE1

    WHERE

    ((EMP_ID='abc' AND EMP_NAME='abc' AND EMP_NO='20' AND EMP_REG=[1,4,5,6] AND EMP_status='A') OR
       (EMP_ID='xyz' AND EMP_NAME='acd' AND EMP_NO='10' AND EMP_REG=[9,10] AND EMP_status='A'} OR

          …
          ….
          … ))

    Is there a concept 'JSON Parser' in PL/I? Any leads would be appreciated.

    Thanks,

    Aswini Abraham



    ------------------------------
    Aswini Abraham
    ------------------------------


  • 2.  RE: JSON Parser in PL/I

    Posted Mon July 24, 2023 02:41 PM

    I'd have a look at the z/OS Client Web Enablement Toolkit:  https://www.ibm.com/docs/en/zos/2.5.0?topic=languages-zos-client-web-enablement-toolkit.

    z/OS Client Web Enablement Toolkit

    Description:
    Applications running in traditional z/OS environments can choose to play the client role of a RESTful web application and initiate a request to a web server residing on z/OS or any other platform supporting web applications. In z/OS Version Release 2, the new z/OS Client Web Enablement toolkit enables these applications to more easily participate in this client/server space by providing a built-in:
    • z/OS JSON parser to parse JSON text coming from any source and the ability to build new JSON text or add to existing JSON text.
    • z/OS HTTP/HTTPS protocol enabler using interfaces similar in nature to other industry-standard APIs.

    The intention of the toolkit is to enable traditional z/OS programs apart from a Java Virtual Machine (JVM) environment to have easy access to these types of services. Programs running as a batch job, as a started procedure or running in almost any address space on a z/OS system now have APIs that they can utilize in a similar manner to any standard z/OS APIs provided by the operating system. Furthermore, programs can invoke these APIs in the programming language of their choice. C/C++, COBOL, PL/I, and Assembler languages are fully supported.



    ------------------------------
    Scott Fagen
    Mainframe Evangelist
    CDW
    www.cdw.com/content/cdw/en/solutions/ibm-zsystems.html
    ------------------------------



  • 3.  RE: JSON Parser in PL/I

    Posted Mon July 24, 2023 03:15 PM

    Thank you Scott for the details. I would like to know more about the option - 

    • z/OS JSON parser to parse JSON text coming from any source and the ability to build new JSON text or add to existing JSON text.

    I am new to IBM explorer for z/OS. I am able to create service and API using z/OS connect and I could test a few services successfully by sending request JSON and receiving expected response JSON.  So can you please guide on how to check for z/OS JSON parser in z/OS connect. So does this require change in both service/API and application program(PL/I)? Can you please provide a sample code/pseudo code for implementing this.

    Thanks,

    Aswini Abraham



    ------------------------------
    Aswini Abraham
    ------------------------------



  • 4.  RE: JSON Parser in PL/I

    Posted Mon July 24, 2023 04:17 PM

    I haven't programmed in PL/I since the early 1980s.  I was merely pointing out the existence of the services you asked for and the doc that describes them.

    Here is a link to a TechChannel tech tip that talks about how to get a program to use these services:  https://techchannel.com/Enterprise/07/2021/json-z-os-program.

    Happy parsing,

    Scott



    ------------------------------
    Scott Fagen
    Mainframe Evangelist
    CDW
    www.cdw.com/content/cdw/en/solutions/ibm-zsystems.html
    ------------------------------



  • 5.  RE: JSON Parser in PL/I

    Posted Mon July 24, 2023 04:23 PM

    Sure Scott, I will have a look at it. Thank you for your time and help!

    Thanks,

    Aswini Abraham



    ------------------------------
    Aswini Abraham
    ------------------------------



  • 6.  RE: JSON Parser in PL/I

    Posted Tue July 25, 2023 08:47 PM

    Hi Aswini,

    If you haven't already, please refer to the Enterprise PL/I Language Reference and the Programming Guide.  IBM Enterprise PL/I has built-in functions that support JSON parsing.

    hope this helps,



    ------------------------------
    Linda Chui
    Compilation Technology & Enterprise Products
    IBM Canada
    ------------------------------



  • 7.  RE: JSON Parser in PL/I

    Posted Wed July 26, 2023 02:20 AM

    > IBM Enterprise PL/I has built-in functions that support JSON parsing.

    That's certainly a better answer than using the callable services library.  Live and learn!

    Scott



    ------------------------------
    Scott Fagen
    Mainframe Evangelist
    CDW
    www.cdw.com/content/cdw/en/solutions/ibm-zsystems.html
    ------------------------------