Skip to content

Latest commit

 

History

History
41 lines (29 loc) · 658 Bytes

README.md

File metadata and controls

41 lines (29 loc) · 658 Bytes

xml-to-json

Utility for converting between XML and JSON formats, with the added ability to prettify both XML and JSON strings.

Usage

var json = xmlToJson("<a/>");

// {
//   "a": {
//     "-self-closing": "true"
//   },
//   "#omit-xml-declaration": "yes"
// }

var prettyXml = formatXml("<a><b/></a>");

// <a>
//   <b/>
// </a>

var xml = jsonToXml("{}");

// <?xml version="1.0" encoding="UTF-8"?>
// <root></root>

var xml = jsonToXml("{}", "myroot");

// <?xml version="1.0" encoding="UTF-8"?>
// <myroot></myroot>

var prettyJson = formatJson('{"a":{"b":true}}');

// {
//    "a": {
//       "b": true
//    }
// }