{"name":"simple-xml-to-json","description":"Convert XML to JSON - Fast & Simple","keywords":["xml","json","ast","fast","lightweight","simple"],"homepage":"https://github.com/nirgit/xml-to-json","license":"MIT","version":"1.0.6","author":{"name":"Nir Moav","email":"getnirm@gmail.com"},"main":"src/xmlToJson.js","scripts":{"example":"node example/example.js","test":"npx jest"},"repository":{"type":"git","url":"git+https://github.com/nirgit/xml-to-json.git"},"devDependencies":{"kind-of":">=6.0.3","chalk":"^3.0.0","jest":"^24.9.0"},"gitHead":"d66bca95b8fc6ac0f8183da91e4108bcb4bd7b1d","bugs":{"url":"https://github.com/nirgit/xml-to-json/issues"},"_id":"simple-xml-to-json@1.0.6","_nodeVersion":"11.15.0","_npmVersion":"6.7.0","dist":{"integrity":"sha512-81yQxkQFg3n5yHU5o/pIo9ooQlYlCP9Ck846KS2VQzWC2SE6U9hy9xsPosBrNJPPikCTOYUAIoqTPB35X2gbUg==","shasum":"b9161ba1d69084ce9df50c7da72c57aba48d6f4a","tarball":"http://registry-npm.ywwl.com/simple-xml-to-json/download/simple-xml-to-json-1.0.6.tgz","fileCount":15,"unpackedSize":37854,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJek5rKCRA9TVsSAnZWagAAeEgP/RaWTV2gEw4BQ0LcARkd\nxCpM/s6Jka/xL8fxXOT3BLbUDRkEbuXlpao8g1FAv2U2bdDP64ycX7Nd5Fz7\n4McOL5ip9W20rW4FOCD7ATprC2dXslwZQnK6YGMewcZVjP/UWZ56c2g5c0KK\nlu+/2q11KQbHf78PiwESYt8BrLTnBP9HmygbGzIpeDWdQrlLl9FNPZplsj/X\niLfXSsEthI46h4yrqUl2m2GTtVSIuBfYK57HMkjPqwXd3UySkgkQteySLe+T\n47kWrwWnZsA7nrGR/uXQxagE9hIcZsR/cB4XB7CiiBlDBCMtWFvuhqIeQEmV\n5JM7l79EiaBEMoPAllbAWbFe1chEPSGlOlJWg2lVHqRYmukN4VOR8KzBntem\narWHU03Txy2JNCcUUqKtvOGYPNtRfBgTohesZBS3l05nvJSQiYG0Lj99B5in\nEyxiQV8sdKHVEOOli3SJNmo2L73jrfpC32Bewv6pKVGisBmHLpLCupwm5gGF\nmjhejEogvGe3pvfdh/Gtzz/jVB8kLiUCVOuQXpuNhRCuRKfHKM6FlnwANi3p\nZpMtPlyrZ5Wlxc/zDXf/dgAJG4F1FAqInZQZ3wefI275pWkHXA4JyZ3TouSC\nOrBzgffB1yx5xZpZHovmwiu8kDr1uFL4WrGXkYTvxHLDxF5z/z9iPMu1XBHD\nhYEN\r\n=ASKM\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEuXYwzjRfIyEZMgMt4qp550Q9XVlDHB8SbJyhRbLyduAiEAuQ+BNELGBq9FQhi5q5HYFk1dNZ1SKZS52YTP07T4UCg="}],"size":7892,"noattachment":false,"key":"/simple-xml-to-json/-/simple-xml-to-json-1.0.6.tgz"},"maintainers":[{"name":"nirmoav","email":"getnirm@gmail.com"}],"_npmUser":{"name":"nirmoav","email":"getnirm@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-xml-to-json_1.0.6_1586731721484_0.3359725812117407"},"_hasShrinkwrap":false,"readme":"# A simple XML to JSON converter\n\n[![npm version](https://img.shields.io/npm/v/simple-xml-to-json.svg?style=flat-square)](https://www.npmjs.com/package/simple-xml-to-json)\n[![Test CI](https://github.com/nirgit/simple-xml-to-json/actions/workflows/node.js.yml/badge.svg)](https://github.com/nirgit/simple-xml-to-json/actions/workflows/node.js.yml)\n[![codecov](https://codecov.io/gh/nirgit/simple-xml-to-json/branch/master/graph/badge.svg?token=XW7CWWM4RV)](https://codecov.io/gh/nirgit/simple-xml-to-json)\n\n## Install\nSimply install using NPM in your project directory\n> npm install simple-xml-to-json\n\n\n## Usage and API\n### 1. convertXML(xmlToConvert [,customConverter])\n   * `xmlToConvert` \\<string\\>\n   * `customConverter` \\<function\\>\n   * Returns: \\<JSON\\> by default or other if `customConverter` is used\n   \n### 2. createAST(xmlToConvert)\n   * `xmlToConvert` \\<string\\>\n   * Returns: An AST representation of the XML \\<JSON\\>\n\nCode Example:\n```javascript\nconst {convertXML, createAST} = require(\"simple-xml-to-json\")\n\nconst myJson = convertXML(myXMLString)\nconst myYaml = convertXML(myXMLString, yamlConverter)\nconst myAst = createAST(myXMLString)\n````\n\n---\n### ![TS](https://raw.githubusercontent.com/nirgit/assets/master/simple-xml-to-json/ts_icon_32.png) Typescript compatible\n---\n\n## Notes and how to use code\n1. The easiest thing to start is to run `node example/example.js` in your terminal and see what happens.\n2. There's the `xmlToJson.js` file for convenience. Just pass in the XML as a String.\n3. It's MIT licensed so you can do whatever :)\n4. Profit\n\n## How this works in a nutshell\n1. The library converts the XML to an AST\n2. There is a JSON converter that takes the AST and spits out a JSON\n3. You can write your own converters if you need XML-to-ANY-OTHER-FORMAT\n\n## Benchmark\n\n_Take these results with a grain of salt._\\\nAccording to a __simple__ benchmark test I performed in __April 2024__ with a random XML. _YMMV_.\n![Benchmark Chart](https://github.com/nirgit/assets/blob/master/simple-xml-to-json/simple-xml-to-json-benchmark-2.png?raw=true)\n\n* The chart results __may be__ outdated. [Run the test yourself](https://runkit.com/nirgit/6620cf27943a41000847221d)\n\n\n## Current Drawbacks\n1. All values are translated to strings in JSON\n2. There are currently reserved words in the JSON converter: \n    * \"content\" \n    * \"children\"\n\n    so you cannot by default have an attribute with that name and free text as the content of the element or have nested elements as children.\n    \n    *If you need to, you can write your own converter from the AST created by the parser, and pass it as a 2nd parameter after the xml string*\n","publish_time":1586731721668,"_cnpm_publish_time":1586731721668,"dist-tags":{"latest":"1.2.7"}}