{"name":"simple-xml-to-json","description":"Convert XML to JSON - Fast & Simple","keywords":["xml","json","simple","fast","lightweight","ast"],"homepage":"https://github.com/nirgit/simple-xml-to-json","license":"MIT","version":"1.1.0","author":{"name":"Nir Moav","email":"getnirm@gmail.com"},"contributors":[{"name":"Nir Moav","email":"getnirm@gmail.com","url":"https://nirgit.github.io/"}],"main":"src/xmlToJson.js","scripts":{"prettify":"prettier --write ./**/*.js","example":"node example/example.js","test":"npx jest"},"repository":{"type":"git","url":"git+https://github.com/nirgit/simple-xml-to-json.git"},"bugs":{"url":"https://github.com/nirgit/simple-xml-to-json/issues"},"dependencies":{},"devDependencies":{"jest":"^24.9.0","prettier":"2.6.1"},"engines":{"node":">=10.18.0"},"gitHead":"46944838e635d980029aeb331e520165e0170165","_id":"simple-xml-to-json@1.1.0","_nodeVersion":"14.17.0","_npmVersion":"7.19.1","dist":{"integrity":"sha512-xfKFWbD2ssGpIw3/upsFjQIzaDv2VSr405Z7n5s03CVOS8TB1INp/X7Dfr3ZgyTNb/HZ4smxqjtRRMOmTktkmA==","shasum":"b3f2d7864d4dfab6bed30dc98414e9299929e3f7","tarball":"http://registry-npm.ywwl.com/simple-xml-to-json/download/simple-xml-to-json-1.1.0.tgz","fileCount":23,"unpackedSize":101129,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDtJ32YSKwV2GflvvvM/1jKB6JDrX3Irc3JIX1fUO0e0gIgCNC0bX92um8Wk+YbcxRz4znk21Ao4JL8UEY05o0YCFA="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkRYAFACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpUbA//e4imyRxkL1eCTKiy18msuamLyrWCqRkvVlYrmCekD5/jSTg2\r\n4sD2QevwfJXH7xVU2sfZJciF2kCnu01T+H+bl0uQHH6/cccfCAP7m4+q7roN\r\n5XXGfiXw8sn6kbVGvZ2Ax73kdRR3nH69SY1owSSJslADTFYrl5MFhIcIQ/ZS\r\n1GRDKT76T+v59zos0/PFJ72wCP6hZ9muDukZZ/jlH572xUwZyJXp4PHJj4VQ\r\nB2bRbPfxq8LQYjUP6TbX/dGDfaosI5GMR1sJmXHNfgICTxpP0apGAAT5jVdI\r\nLhRiR7tUxf8CwiLZ4D3MeRWeSWlWnvLGvf6qm8KoToxLfuiBn/6QRr2DflEA\r\nwm4DTj91LDzOatQU5VrNt6wVaOgc5O+yLQm7ETxAaE/U84d4unvngaOXN8NR\r\nwAWSWrZFLfuXKeD5LAVng+rI6h4xQ6nos63IAxumQZ3r2KuQM1XJO9b7KlVu\r\nXBfmw2TLvCGXq7f6rVHTXKIR6Qf0PD5bv4dOQfEaBHc0FUxmlWYvMjVqVZh9\r\njv+nYRbMPXzQqHpgTlTArLXDN4HCIOkJyR7fi5+dc+/b5lGpK55T7OHCEj79\r\n7MuKX1MbEy+2AunsjUPfaEjUYQbUl/QD/rs5hyxpkFsIPiGNbJTNKScU03eW\r\nQ2QEboe9ANpqfpZQihLGtn8HyreK78zqCB0=\r\n=PZen\r\n-----END PGP SIGNATURE-----\r\n","size":31575,"noattachment":false,"key":"/simple-xml-to-json/-/simple-xml-to-json-1.1.0.tgz"},"_npmUser":{"name":"nirmoav","email":"getnirm@gmail.com"},"directories":{},"maintainers":[{"name":"nirmoav","email":"getnirm@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-xml-to-json_1.1.0_1682276356960_0.470417186872631"},"_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":1682276357198,"_cnpm_publish_time":1682276357198,"dist-tags":{"latest":"1.2.7"}}