Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ricardofbarros/parser-xml2json
:fire: Blazing fast XML parser to JSON for Node.js written in Rust :fire:
https://github.com/ricardofbarros/parser-xml2json
json xml xml-parser xml2js xml2json
Last synced: about 1 month ago
JSON representation
:fire: Blazing fast XML parser to JSON for Node.js written in Rust :fire:
- Host: GitHub
- URL: https://github.com/ricardofbarros/parser-xml2json
- Owner: ricardofbarros
- Created: 2017-02-23T23:47:45.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-31T14:47:03.000Z (over 7 years ago)
- Last Synced: 2024-08-02T05:13:32.543Z (4 months ago)
- Topics: json, xml, xml-parser, xml2js, xml2json
- Language: JavaScript
- Size: 6.84 KB
- Stars: 28
- Watchers: 1
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-blazingly-fast - parser-xml2json - :fire: Blazing fast XML parser to JSON for Node.js written in Rust :fire: (JavaScript)
README
# Parser XML 2 JSON
Blazing fast XML parser to JSON written in Rust ([node2object](https://github.com/vorot93/node2object)).
## Requirements
- `rust`
- `cargo`
- [`node-gyp requirements`](https://github.com/nodejs/node-gyp#installation)## Usage
```js
const parser = require('parser-xml2json')const xml = `
Alex
173.5
Mel
180.4
`parser.parseString(xml, (err, res) => {
...
})parser.parseFile('/a/xml/file/somewhere.xml', { object: true }, (err, res) => {
...
})```
## API
### `parseString(xmlString[, options], callback)`
- `xmlString` - A string that represents an XML
- `options` - an optional object where:
- `object` - Parse JSON string to Object. default `false`
- `callback` - a function with the signature `function (err, result)`### `parseFile(filePath[, options], callback)`
- `filePath` - Relative or absolute path to an `.xml` file
- `options` - an optional object where:
- `object` - Parse JSON string to Object. default `false`
- `callback` - a function with the signature `function (err, result)`## Benchmark
Results from a i7 2.2 Ghz```
Package Time taken
---------------------- ----------
parser-xml2json (rust) 0.0468 s
xml2js (js) 0.1286 s
xml2json (js and c++) 0.1329 s
```### How to run the benchmark script on your machine
```
npm i
npm i benchmark/
node benchmark/index.js
```## License
MIT