1.0.5 • Published 6 years ago

raw-js2yaml v1.0.5

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

raw-js2yaml

Installation

$ npm install raw-js2yaml

Usage

Unlike js-yamljson-to-pretty-yaml or other packages, The purpose of this package is to convert json object to yaml string without converting json value(double quotes json values), that is why called raw.

Example

const js2YamlString = require("raw-js2yaml");
const obj = {
  a: 'this ia a',
  b: 'this is b',
  '/api/users/{id}': 'this is string',
  c: [1,2,3,4],
  d: [{
    a: 'a',
    b: 'b',
    c: 'c',
  }, {
    a2: 'a2',
    b2: 'b2',
    c2: 'c2',
  }],
  e: 123,
};
const str = js2YamlString(obj);
const fs = require('fs');
fs.writeFileSync('test.yaml', str);

Output like this:

a: this ia a
b: this is b
/api/users/{id}: this is string
c:
  - 1
  - 2
  - 3
  - 4
d:
  - a: a
    b: b
    c: c
  - a2: a2
    b2: b2
    c2: c2
e: 123

License

MIT

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago