xtract.bot
POST /api/json-to-xml

Convert JSON to XML. Object keys become element names; values become element text; keys prefixed `@_` become attributes; arrays become repeated sibling elements.

Translates JSON to XML. Object keys become element names; values become element text; arrays become repeated sibling elements; keys with the `@_` prefix become attributes on the parent element. Options: - `prolog` (default true): include the `<?xml version="1.0" …?>` declaration at the top. - `indent` (default 2): pretty-print indent. Set to `0` for compact single-line output. - `rootName` (default `root`): wrapper element name.

Inputs

NameTypeDefaultDescription
json*stringJSON object as a string.
indentnumber (0…8)2Indent width in spaces (0 = single-line).
declarationbooleantruePrepend `<?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!\"}}"
}'