JSON to XML Activity

Overview

The JSON to XML activity converts JSON documents to XML. Define your XML structure within jsonContent, and optionally configure namespaces, XML declaration, and output formatting options.


Activity Configuration

Option
Type
Default
Description

prettyPrint

boolean

false

Format output with indentation and newlines

skipEmptyElements

boolean

false

Exclude elements with empty string values

skipEmptyAttributes

boolean

false

Exclude attributes with empty string values

skipNullElements

boolean

true

Exclude elements with null values

skipNullAttributes

boolean

true

Exclude attributes with null values

Empty and Null Handling

Input:

{
  "jsonContent": {
    "Order": {
      "_attributes": {
        "id": "ORD-001",
        "priority": "",
        "region": null
      },
      "Name": "Test Order",
      "Description": "",
      "Notes": null
    }
  }
}

Output with defaults (skipEmpty*=false, skipNull*=true):

Output with skipEmptyElements=true, skipEmptyAttributes=true:


Schema Structure

Field
Required
Description

$schema

No

Schema reference for validation

_declaration

No

XML declaration. If omitted, no <?xml?> header is added

_namespaces

No

Namespace declarations. If omitted, produces simple XML

jsonContent

Yes

Your XML content definition


Basic Elements

JSON keys become XML element names. Simple values become text content.

JSON:

XML:


Adding Attributes

Use _attributes to add XML attributes to an element.

JSON:

XML:


Adding Namespaces

  1. Declare namespaces in _namespaces (use default for the default namespace)

  2. Use _ns on elements to apply a namespace prefix

  3. Child elements inherit the parent's namespace prefix

JSON:

XML:

Note: Using an undeclared namespace prefix will result in an error.


Repeating Elements (Arrays)

Use JSON arrays for repeating XML elements.

JSON:

XML:


Special Content

Field
Purpose
Use Case

_text

Plain text content

Mixed content or explicit text

_cdata

CDATA section

Content with special characters (<, >, &)

_comment

XML comment

Documentation within XML

JSON:

XML:


Quick Reference

JSON
XML Result

"Name": "John"

<Name>John</Name>

"_attributes": { "id": "1" }

id="1" on element

"_ns": "cust"

cust: prefix on element and children

"Item": [{...}, {...}]

Multiple <Item> elements

"_text": "Hello"

Text content

"_cdata": "<raw>"

<![CDATA[<raw>]]>

"_comment": "Note"

<!-- Note -->


Complete Example

XML Output:

Last updated

Was this helpful?