Transforming application data to JSON 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 application data to JSON by linking to DFHJSON.

Before you begin

You must have an enabled JSONTRANSFRM bundle 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. The application program must create a channel, for example MyChannelName , and put the following containers into the channel.
    • DFHJSON-DATA
    • DFHJSON-TRANSFRM
    • DFHJSON-JVMSERVR (optional)
    For more information about these containers, see JSON transformer linkable interface containers .
  2. Use the EXEC CICS LINK PROGRAM 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.

  4. Get container DFHJSON-JSON and make use of the JSON in your application.
  5. Install the application.

Results

When the application runs the LINK command, CICS checks the JSONTRANSFRM bundle resource to find the mappings in the JSON binding and transforms the application binary data to JSON by using the containers on the channel. The JSON is placed in the DFHJSON-JSON container on return. The JSON conforms to the JSON schema that is defined in the JSONTRANSFRM bundle resource.

What to do next

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