Operations (sample payloads)

Main operations

Convert JSON to XML

Takes JSON as an input and converts to XML. Sample Input

{
    "json_to_parse": {
        "order": {
            "id": "12345",
            "customer": \{
                "name": "John Doe",
                "email": "john.doe@example.com"
            \},
            "items": [
                \{
                    "product": "Widget A",
                    "quantity": 2,
                    "price": 9.99
                \},
                \{
                    "product": "Gadget B",
                    "quantity": 1,
                    "price": 24.99
                \}
            ],
            "total": 44.97
        }
    }
}

Sample Output

\{
    "xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<order>\n  &lt;id>12345&lt;/id&gt;\n  <customer>\n    &lt;name>John Doe&lt;/name&gt;\n    <email>john.doe@example.com</email>\n  </customer>\n  <items>\n    <item>\n      <product>Widget A</product>\n      <quantity>2</quantity>\n      <price>9.99</price>\n    </item>\n    <item>\n      <product>Gadget B</product>\n      <quantity>1</quantity>\n      <price>24.99</price>\n    </item>\n  </items>\n  <total>44.97</total>\n</order>"
\}

Convert XML to JSON

Takes XML as an input and converts to JSON. Sample Input

\{
    "xml_to_parse": "<book>\n  <title>The Great Gatsby</title>\n  <author>F. Scott Fitzgerald</author>\n  <year>1925</year>\n  <genres>\n    <genre>Novel</genre>\n    <genre>Fiction</genre>\n  </genres>\n</book>",
    "reversible": false,
    "keys_array": [
        "genres"
    ]
\}

Sample Output

{
    "xml": {
        "book": \{
            "title": "The Great Gatsby",
            "author": "F. Scott Fitzgerald",
            "year": "1925",
            "genres": [
                "Novel",
                "Fiction"
            ]
        \}
    }
}

Paginate XML file

Read a XML file and paginate the root or selected element. Sample Input

{
    "file": \{
        "name": "users.xml",
        "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><users><user>&lt;id>1&lt;/id&gt;&lt;name>John Doe&lt;/name&gt;</user><user>&lt;id>2&lt;/id&gt;&lt;name>Jane Smith&lt;/name&gt;</user><user>&lt;id>3&lt;/id&gt;&lt;name>Bob Johnson&lt;/name&gt;</user><user>&lt;id>4&lt;/id&gt;&lt;name>Alice Brown&lt;/name&gt;</user><user>&lt;id>5&lt;/id&gt;&lt;name>Charlie Davis&lt;/name&gt;</user></users>"
    \},
    "xpath": "/users/user",
    "page_size": 2,
    "page_number": 1
}

Sample Output

\{
    "result": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><users><user>&lt;id>3&lt;/id&gt;&lt;name>Bob Johnson&lt;/name&gt;</user><user>&lt;id>4&lt;/id&gt;&lt;name>Alice Brown&lt;/name&gt;</user></users>"
\}

Was this page helpful?