{"name":"simple-xml-to-json","description":"Convert XML to JSON - Fast & Simple","keywords":["XML","xml","JSON","json","js","xml2json","xml2js","convertor","conversion","parsing","parser","AST","ast","simple","fast","lightweight","small"],"homepage":"https://github.com/nirgit/simple-xml-to-json","license":"MIT","version":"1.2.3","author":{"name":"Nir Moav","email":"getnirm@gmail.com"},"contributors":[{"name":"Nir Moav","email":"getnirm@gmail.com","url":"https://nirgit.github.io/"}],"main":"lib/simpleXmlToJson.min.js","typings":"typings/simple-xml-to-json.d.ts","scripts":{"build":"npm run clean && rollup -c --inline","clean":"rm -rf ./lib/ && mkdir lib ","lint":"eslint ./src ./test","prettify":"prettier --write ./**/*.js","example":"node example/example.js","test":"jest ","make-new-release-lib":"npm run validate-lib-health && sh ./scripts/make-new-release.sh","validate-lib-health":"npm run prettify && npm run lint && npm test"},"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"},"devDependencies":{"@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-replace":"^5.0.5","@rollup/plugin-terser":"^0.4.4","acorn":"^8.11.3","acorn-walk":"^8.3.2","eslint":"^9.1.1","eslint-config-prettier":"^9.1.0","eslint-plugin-jest":"^28.3.0","globals":"^15.1.0","jest":"^29.7.0","magic-string":"^0.30.10","prettier":"3.2.5","rollup":"^4.17.1"},"engines":{"node":">=20.12.2"},"_id":"simple-xml-to-json@1.2.3","gitHead":"fd80a141ba383061b202c28916a62046e77b8ef9","_nodeVersion":"20.12.2","_npmVersion":"10.5.0","dist":{"integrity":"sha512-kWJDCr9EWtZ+/EYYM5MareWj2cRnZGF93YDNpH4jQiHB+hBIZnfPFSQiVMzZOdk+zXWqTZ/9fTeQNu2DqeiudA==","shasum":"79c7188ff99ae209a267b70ee0db06b0e4597787","tarball":"http://registry-npm.ywwl.com/simple-xml-to-json/download/simple-xml-to-json-1.2.3.tgz","fileCount":6,"unpackedSize":25634,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCF55xH3MkmdQKPuTl54CAZ8bjdsLwFYO8xDWqoLkBQ5wIhAJCQbCHGqfXWsNT7fTv0UaCQYpPKx//afw7hIbEnpZFA"}],"size":7951,"noattachment":false,"key":"/simple-xml-to-json/-/simple-xml-to-json-1.2.3.tgz"},"_npmUser":{"name":"nirmoav","email":"getnirm@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-xml-to-json_1.2.3_1726339952910_0.5739408725952089"},"_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":1726339953113,"maintainers":[{"name":"nirmoav","email":"getnirm@gmail.com"}],"_cnpm_publish_time":1726339953113,"dist-tags":{"latest":"1.2.7"}}