This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
admin-panel/graphql-types/node_modules/json-to-pretty-yaml
2021-03-09 19:44:13 +01:00
..
.npmignore add configured graphql-codegen 2021-03-09 19:44:13 +01:00
index.js add configured graphql-codegen 2021-03-09 19:44:13 +01:00
index.test.js add configured graphql-codegen 2021-03-09 19:44:13 +01:00
LICENSE add configured graphql-codegen 2021-03-09 19:44:13 +01:00
package.json add configured graphql-codegen 2021-03-09 19:44:13 +01:00
README.md add configured graphql-codegen 2021-03-09 19:44:13 +01:00

♻️ json-to-pretty-yaml

A node module to convert JSON to pretty YAML

Installation

npm install --save json-to-pretty-yaml

Usage

index.js

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

{
  "a": 1,
  "b": 2,
  "c": [
    {
      "d": "cool",
      "e": "new"
    },
    {
      "f": "free",
      "g": "soon"
    }
  ]
}

output.yaml

a: 1
b: 2
c:
  - d: "cool"
    e: "new"
  - f: "free"
    g: "soon"

Testing

npm test