Transforming application data to JSON by using the TRANSFORM DATATOJSON API command

You can use the TRANSFORM DATATOJSON API command in your application to transform application data to JSON.

Before you begin

You must have an enabled JSONTRANSFRM resource that defines the JSON binding and JSON schema.

About this task

The application must use a channel-based interface.

Procedure

  1. Create a channel and put into the channel an input container that contains the application data to be converted.
    Note: This channel will also have an output container that contains the JSON output when the TRANSFORM DATATOJSON command completes. Do not create the output container before issuing TRANSFORM DATATOJSON because the container is created and populated as part of the command itself.
  2. Use the TRANSFORM DATATOJSON command to transform the data to JSON.
    For example:
    
    EXEC CICS TRANSFORM DATATOJSON CHANNEL(
    ChannelName
    ) INCONTAINER(
    InpContainerName
    ) OUTCONTAINER(
    OutContainerName
    ) TRANSFORMER(
    BundleName
    )
    

Results

When the application runs the TRANSFORM DATATOJSON 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. On return, the JSON is placed in the container that is specified in the OUTCONTAINER option of the TRANSFORM DATATOJSON command. If the option is omitted, DFHJSON-JSON is used by default. The JSON conforms to the JSON schema that is defined in the JSONTRANSFRM bundle resource.