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 <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>"
\}
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><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>"
\},
"xpath": "/users/user",
"page_size": 2,
"page_number": 1
}
Sample Output
\{
"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>"
\}