Skip to content

Read XML/JSON as JSON Activity

The Read XML/JSON as JSON activity parses either XML or JSON content — from a specified file path or a direct string — and stores the result into a designated JSON type variable. This removes the need for a Script Task or an external library (such as xml2json or DOMParser) when a process must work with XML content as JSON.

Field Description Requirement
File Name Specifies the full path to the XML or JSON file to be read. Required
XML/Json string Provides the XML- or JSON-formatted string content to be parsed. Required
Result variable name Defines the name of the variable where the parsed JSON data will be stored. Required

Action Types & Examples

JSON Output Variable

  • Format: JSON object or JSON array
  • Example Result: resultJson

XML Input

  • Format: XML string or file
  • Example Result: <root><id>1</id></root> parsed into { "root": { "id": "1" } }

Implementation Examples

Field Setup - File Name: C:RobustaXml-JsonreadJsontest.json - XML/Json string: [{ "id": 1 }] - XML/Json string: { "id": 1, "firstname": "Katerina", "job": { "site": "www.javacodegeeks.com", "name": "Java Code Geeks" } } - XML/Json string: <root><id>1</id></root> - Result variable name: resultJson

Execution Parameters - Example 1 (Reading from File): - File Name: C:RobustaXml-JsonreadJsontest.json - Result variable name: resultJson - Example 2 (Reading from String): - XML/Json string: [{ "id": 1 }] - Result variable name: resultJson - Example 3 (Converting XML to JSON): - XML/Json string: <root><id>1</id></root> - Result variable name: resultJson

Technical Notes

The activity requires either the File Name or the XML/Json string parameter to be provided, but not necessarily both simultaneously for a single execution. It automatically detects whether the input is XML or JSON and parses it accordingly, storing the result as a JSON structure in the output variable. Ensure the input adheres to standard XML or JSON syntax for successful parsing.