Transforming JSON to application data by linking to DFHJSON

The JSON transformer linkable interface DFHJSON is a CICS®-supplied program that can be called to perform transformation between application data and JSON. Your application program can transform JSON to application data by linking to DFHJSON.

Note: EXEC CICS TRANSFORM JSONTODATA and TRANSFORM DATATOJSON commands supersede the linkable interface, DFHJSON, making it possible to convert JSON data to a language structure, or vice versa, in your application.

Before you begin

You must have an enabled JSONTRANSFRM resource that defines the JSON binding and JSON schema. If you intend to perform transformations by using Java™, you must have an Axis2 JVM server already running.

About this task

Create or update an application program to link to the CICS supplied program DFHJSON to do the transformation.

Procedure

  1. Create a channel, for example MyChannelName, and put the following containers into the channel.
    • DFHJSON-JSON
    • DFHJSON-TRANSFRM
    • DFHJSON-JVMSERVR

    For more information about these containers, see JSON transformer linkable interface containers.

  2. Use the EXEC CICS LINK PROGRAM API command to transform the data to JSON:

    EXEC CICS LINK PROGRAM('DFHJSON') CHANNEL('MyChannelName')

  3. Get containers DFHJSON-ERROR and DFHJSON-ERRORMSG, and check if any errors occurred during the transformation.

    If a problem occurs during the transformation, an error code is returned in the DFHJSON-ERROR container and a detailed message in the DFHJSON-ERRORMSG container. For more troubleshooting information, see Troubleshooting problems with JSON requests. For information about the errors that are generated during validation or execution of DFHJSON, see DFHJSON-ERROR container.

  4. Install the application program.

Results

When the application runs the LINK PROGRAM command, CICS checks the JSONTRANSFRM resource to find the mappings in the JSON binding and transforms the JSON to the application data using the containers on the channel. The application data is placed in the DFHJSON-DATA bit container on return.

What to do next

You can also use the same mappings to transform application data to JSON. For more information, see Transforming application data to JSON by linking to DFHJSON.