Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexcrist/json-to-pretty-yaml
A node module to convert JSON to pretty YAML
https://github.com/alexcrist/json-to-pretty-yaml
json npm yaml
Last synced: 3 months ago
JSON representation
A node module to convert JSON to pretty YAML
- Host: GitHub
- URL: https://github.com/alexcrist/json-to-pretty-yaml
- Owner: alexcrist
- License: apache-2.0
- Fork: true (coolaj86/json2yaml)
- Created: 2018-04-26T22:13:12.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-03-20T11:37:20.000Z (almost 4 years ago)
- Last Synced: 2024-09-25T21:19:53.600Z (3 months ago)
- Topics: json, npm, yaml
- Language: JavaScript
- Homepage:
- Size: 28.3 KB
- Stars: 15
- Watchers: 3
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ♻️ json-to-pretty-yaml
> A node module to convert JSON to pretty YAML
## Installation
`npm install --save json-to-pretty-yaml`
## Usage
#### `index.js`
```javascript
const fs = require('fs');
const YAML = require('json-to-pretty-yaml');
const json = require('input.json');const data = YAML.stringify(json);
fs.writeFile('output.yaml', data);
```#### `input.json`
```json
{
"a": 1,
"b": 2,
"c": [
{
"d": "cool",
"e": "new"
},
{
"f": "free",
"g": "soon"
}
]
}
```#### `output.yaml`
```yaml
a: 1
b: 2
c:
- d: "cool"
e: "new"
- f: "free"
g: "soon"
```## Testing
`npm test`