JSON to XML
Try it interactively →POST /api/json-to-xmlConvert JSON to XML. Object keys become element names; values become element text; keys prefixed `@_` become attributes; arrays become repeated sibling elements.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| json* | string | — | JSON object as a string. |
| indent | number (0…8) | 2 | Indent width in spaces (0 = single-line). |
| declaration | boolean | true | Prepend `<?xml version="1.0" encoding="UTF-8"?>`. |
Response
Modes: json, text. Cache: yes (24h TTL).
Code samples
Built from the simple example.
curl -X POST https://api.xtract.bot/api/json-to-xml \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "X-Account-Id: $XTRACT_ACCOUNT_ID" \
-H "X-Api-Key: $XTRACT_API_KEY" \
-d '{
"json": "{\"note\":{\"@_priority\":\"high\",\"to\":\"Tove\",\"from\":\"Jani\",\"body\":\"Don't forget!\"}}"
}'