Configuring a data transform for a JSON output mapping

To support a machine learning service connection to external topic detection models, configure a data transform to convert the JSON response from the prediction endpoint to a format that is accepted in Pega Platform. The output mapping is based on the structure of the Data-NLP-Outcome class.
  1. Create a data transform record in the Data-NLP-ExternalMapping class and using the Clipboard data model format.
    For more information, see Configuring data transforms.
  2. Map the properties in the Data-NLP-Outcome class to the paths in the JSON response.

    Use the following actions, target properties, and source properties for the mapping:

    Data transform actions and properties for a JSON output mapping
    Action Target property Target property description Source property
    Append and Map to .pxResults

    Specifies an array in the JSON response.

    Enter the path in a format that follows the JSON Pointer specification but without a slash (/) as a prefix.

    Example:

    payload
    Note: If you leave the Source field empty, the mapping will point to the following JSON path: /
    Set .pySource_jsonPath

    Specifies a path in the JSON response.

    Enter the path in a format that follows the JSON Pointer specification but without a slash (/) as a prefix.

    Examples:

    classification/score

    displayName

    Set .pyDestination_property Contains the name of a source property in the Data-NLP-Outcome class.

    Property in the Data-NLP-Outcome class:

    .pyTopics

    .pyName

    .pyConfidenceScore

    For more information, see JSON Pointer specification.

  3. Click Save.
Example: 

The following code represents a sample JSON response from a prediction endpoint:

{
  "payload": [
    {
      "annotationSpecId": "2348805326557413376",
      "classification": {
        "score": 0.9609469
      },
      "displayName": "greeting"
    },
    {
      "annotationSpecId": "42962317343719424",
      "classification": {
        "score": 0.026214128
      },
      "displayName": "thanks"
    }
  ]
}

To convert the properties from the JSON response to a format that is accepted in Pega Platform, a data transform is used, as in the following figure:

Figure: Data transform for a sample JSON response

Data transform record showing the output mapping for the sample JSON response

The sample JSON response, contains properties classification/score and displayName in a JSON array property payload.

In the data transform, classification/score and displayName are mapped to the Pega Platform properties .pyConfidenceScore and .pyName. The JSON array property payload is mapped to .pyTopics.

The property .pxResult indicates each node in the JSON array that includes child properties that need to be processed.

What to do next: Complete configuring the machine learning service connection by defining the new data transform as the output mapping. For more information, see Configuring a machine learning service connection for topic detection models using REST API.