@phildinius/xml-to-json
v1.0.3
Published
Convert XML strings into plain JSON objects
Maintainers
Readme
xml-to-json
Convert XML strings into plain JSON objects.
Install
npm i @phildinius/xml-to-jsonUsage
import xmlToJson from "@phildinius/xml-to-json";
const data = xmlToJson(`
<boardgame id="174430">
<name type="primary" value="Gloomhaven" />
<yearpublished value="2017" />
</boardgame>
`);
console.log(data);Output shape
- Element attributes land on a
$object for container nodes, or directly on the value for self-closing / leaf attribute-only nodes. - Text content with attributes is stored as
_content. - Numeric-looking values are coerced to numbers.
- Repeated sibling tags with the same name become arrays.
- HTML entities in text are decoded.
Development
npm install
npm run build
npm test
npm run lintLicense
ISC
