Skip to content

Xml

Overview

Module

XML ↔ JSON conversion via the platform's Jackson XML mapper. Use this to consume legacy SOAP responses without writing schema-derived bindings, or to emit XML payloads from data already shaped as JSON.

The conversion is structural — element / attribute names become JSON keys, text nodes become string values, repeated elements become arrays. Round-tripping is reliable for tree-shaped documents; mixed-content XML (text interleaved with elements) loses some fidelity.

Key Features:

  • Jackson XML-backed — same conversion rules across the platform.
  • String in / string out — no streaming or DOM bookkeeping.

Example Usage:

java
import org.eclipse.dirigible.sdk.utils.Xml;

String json = Xml.toJson("<order><id>42</id><amount>1299</amount></order>");
String xml  = Xml.fromJson("{\"order\":{\"id\":\"42\",\"amount\":\"1299\"}}");

Methods

toJson()

Converts an XML document into its JSON representation.

java
public static String toJson(String xml) throws Exception;
ParameterTypeDescription
xmlStringXML document.

Returns

  • Type: String
  • Description: The JSON form of the input.

fromJson()

Converts a JSON document into XML.

java
public static String fromJson(String json) throws Exception;
ParameterTypeDescription
jsonStringJSON document.

Returns

  • Type: String
  • Description: The XML form of the input. |

Released under the EPL-2.0 License.