Operations (sample payloads)

Main operations
Copy

Convert JSON to XML
Copy

Takes JSON as an input and converts to XML.

Sample Input

1
{
2
"json_to_parse": {
3
"order": {
4
"id": "12345",
5
"customer": {
6
"name": "John Doe",
7
"email": "john.doe@example.com"
8
},
9
"items": [
10
{
11
"product": "Widget A",
12
"quantity": 2,
13
"price": 9.99
14
},
15
{
16
"product": "Gadget B",
17
"quantity": 1,
18
"price": 24.99
19
}
20
],
21
"total": 44.97
22
}
23
}
24
}

Sample Output

1
{
2
"xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<order>\n <id>12345</id>\n <customer>\n <name>John Doe</name>\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>"
3
}

Convert XML to JSON
Copy

Takes XML as an input and converts to JSON.

Sample Input

1
{
2
"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>",
3
"reversible": false,
4
"keys_array": [
5
"genres"
6
]
7
}

Sample Output

1
{
2
"xml": {
3
"book": {
4
"title": "The Great Gatsby",
5
"author": "F. Scott Fitzgerald",
6
"year": "1925",
7
"genres": [
8
"Novel",
9
"Fiction"
10
]
11
}
12
}
13
}

Paginate XML file
Copy

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

Sample Input

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

Sample Output

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