Configuring a data transform for a JSON output mapping
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:
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.