Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/onhernandes/parserblade
The easiest parser for JSON, XML, CSV and YAML. Use it as simple as JSON.stringify() or JSON.parse(). All in one place.
https://github.com/onhernandes/parserblade
csv javascript json parser xml yaml
Last synced: about 1 month ago
JSON representation
The easiest parser for JSON, XML, CSV and YAML. Use it as simple as JSON.stringify() or JSON.parse(). All in one place.
- Host: GitHub
- URL: https://github.com/onhernandes/parserblade
- Owner: onhernandes
- License: mit
- Created: 2020-07-15T21:27:59.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-04-04T02:27:38.000Z (almost 2 years ago)
- Last Synced: 2023-12-07T15:42:35.943Z (about 1 year ago)
- Topics: csv, javascript, json, parser, xml, yaml
- Language: JavaScript
- Homepage: https://onhernandes.github.io/parserblade/
- Size: 1.15 MB
- Stars: 38
- Watchers: 1
- Forks: 4
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# parserblade
![CI](https://github.com/onhernandes/parserblade/workflows/CI/badge.svg?branch=main)
A all-in-one parser for Javascript, heavily inspired by: https://github.com/nathanmac/Parser. It allows you to work with JSON, XML, CSV and YAML more without worrying about which module install. It's designed to work just as `JSON.parse` and `JSON.stringify` does, with some improvements.
See [docs](https://onhernandes.github.io/parserblade) for more info and examples.
## Installation
```sh
$ npm install --save parserblade
```## Usage
Every filetype has two main methods: `stringify()` and `parse()`, both receives two arguments, `data` containing any type of data and an options object.
### CSV
```javascript
const { csv } = require('parserblade')// Parsing
const input = 'title,platform\nStardew Valley,Steam'
const result = csv.parse(input)
console.log(result) // [ { title: 'Stardew Valley', platform: 'Steam' } ]// Stringifying
console.log(
csv.stringify(result)
) // 'title,platform\nStardew Valley,Steam'
```### YAML
```javascript
const { yaml } = require('parserblade')// Parsing
const input = 'title: Stardew Valley\nplatform: Steam'
const result = yaml.parse(input)
console.log(result) // { title: 'Stardew Valley', platform: 'Steam' }// Stringifying
console.log(
yaml.stringify(result)
) // 'title: Stardew Valley\nplatform: Steam'
```### XML
```javascript
const { xml } = require('parserblade')// Parsing
const input = 'lodash'
const result = xml.parse(input)
console.log(result) // { package: 'lodash' }// Stringifying
console.log(
xml.stringify(result)
) // 'lodash'
```## License
MIT ©