Skip to main content
This Groovy script parses XML data coming from the responseBodyTextFromTargetAPI variable, converts its hierarchical structure to JSON format while preserving it, and converts Unicode escape sequences (including Turkish characters in \uXXXX format) to readable real characters and assigns it to the responseBodyTextToClient variable.

Example

Response Coming as XML

Converted JSON Response

Explanation

This script performs the following operations:
  1. XML Cleaning: <?...?> lines in XML are cleaned
  2. XML Parse: XML data is parsed
  3. JSON Conversion: XML structure is converted to JSON format
  4. Unicode Normalization: Unicode escape sequences (including Turkish characters in \uXXXX format) are converted to readable characters
  5. Error Management: Returns error message in JSON format in case of error
This script should be run on the response line (Response Policy) because it uses the responseBodyTextFromTargetAPI and responseBodyTextToClient variables.