Tiny JSON to XML conversion utility.
npm install jtx
import jtx from 'jtx'
const myJson = {
"hello": {
"there": [
{
"i": null,
"am": 1,
"here": undefined
}
]
}
}
console.log(jtx(myJson))
// <hello><there><0><i></i><am>1</am></0></there></hello>
Accepts:
-
String
-
Object
-
Array
XML String
You can pass an optional configuration object as the last parameter:
const myJson = { test: true }
jtx(myJson, { header: true })
// <?xml version="1.0" encoding="UTF-8" standalone="no" ?><test>true</test>
name | type | default |
---|---|---|
header | boolean | false |
Example One:
$ jtx test
test
Example Two:
test.json
{
"hello": "there"
}
$ jtx test.json
<hello>there</hello>
Accepts:
-
String
-
Filepath