XML to JSON

Convert an XML document into JSON format.

Use this when you need JSON-formatted data but only have XML available, such as in document processing or API responses.

{{ XMLtoJSON }}

Parameters

  • None - The XML data should be provided as chained input to this function.

Returns

  • JSON representation of the input XML.
Example Usage

Here’s how to convert XML data into JSON using some sample XML:

<library>
  <book>
    <title>The Great Gatsby</title>
    <author>F. Scott Fitzgerald</author>
    <year>1925</year>
    <genre>Fiction</genre>
  </book>
  <book>
    <title>To Kill a Mockingbird</title>
    <author>Harper Lee</author>
    <year>1960</year>
    <genre>Fiction</genre>
  </book>
</library>=>{{ XMLtoJSON }}=>{{ variable | name: "jsonOutput" }}
<< name: jsonOutput, prompt: false >>

The result will be in JSON format and can be further processed within mAIstro:

{
  "LIBRARY": {
    "BOOK": [
      {
        "TITLE": [
          "The Great Gatsby"
        ],
        "AUTHOR": [
          "F. Scott Fitzgerald"
        ],
        "YEAR": [
          "1925"
        ],
        "GENRE": [
          "Fiction"
        ]
      },
      {
        "TITLE": [
          "To Kill a Mockingbird"
        ],
        "AUTHOR": [
          "Harper Lee"
        ],
        "YEAR": [
          "1960"
        ],
        "GENRE": [
          "Fiction"
        ]
      }
    ]
  }
}

JSON to XML

Transform JSON data into XML format for use in XML-compliant systems.

Use this when you need XML-formatted data but only have JSON available, such as in document processing or API responses.

{{ JSONtoXML }}

Parameters

  • None - The JSON data should be provided as chained input to this function.

Returns

  • XML representation of the input JSON.
Example Usage

Here’s how to convert JSON data into XML using some sample JSON:

{
  "library": {
    "book": [
      {
        "title": "The Great Gatsby",
        "author": "F. Scott Fitzgerald",
        "year": "1925",
        "genre": "Fiction"
      },
      {
        "title": "To Kill a Mockingbird",
        "author": "Harper Lee",
        "year": "1960",
        "genre": "Fiction"
      }
    ]
  }
}=>{{ JSONtoXML }}=>{{ variable | name: "xmlOutput" }}
<< name: xmlOutput, prompt: false >>

The resulting XML will follow the same structure as the original JSON.

<library>
  <book>
    <title>The Great Gatsby</title>
    <author>F. Scott Fitzgerald</author>
    <year>1925</year>
    <genre>Fiction</genre>
  </book>
  <book>
    <title>To Kill a Mockingbird</title>
    <author>Harper Lee</author>
    <year>1960</year>
    <genre>Fiction</genre>
  </book>
</library>

Note

Using these transformations allows for easy data format conversions within mAIstro, enabling smooth data handling across applications. Make sure that the input format aligns with expected syntax to avoid conversion errors.


Ⓒ 2024 NeuralSeek, all rights reserved.