rsa-yamljs
Fork of yamljs (0.2.1) for a purpose. See README for details.
Last updated 5 years ago by saltuka .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install rsa-yamljs 
SYNC missed versions from official npm registry.

rsa-yaml.js

This project is a fork of yaml.js Please check it's documentation first.

In this fork I have made below changes on JSON to YAML converter (Dumper.js).

-) In JSON key-value pairs, YML output of string values are wrapped with single quotes by default.

-) A configuration metadata JSON object can be passed as last parameter to Dumper function so that selected values can be wrapped in double quotes.

Sample use

fs   = require('fs');
yaml = require('./');

var my_json = { key1: "value1",
    key2: "value2",
    key3: "value3",
    key4: 5,
    key5: true
};

var metadata_conf = { double_quotes:
    [ 'key1',
        'key2' ] };


var yml_out = yaml.dump(my_json, null, null, null, null, metadata_conf);
fs.writeFile('out.yml', '---\n' + yml_out , function(err) {
    if(err) {
        console.log(err);
    } else {
        console.log("The file was saved!");
    }
});

For this sample values for key1, key2 will be double quoted, and value for key3 will be single quoted in the generated file.

Use with node.js

Install module:

npm install rsa-yamljs

Hope it helps someone out there. As a side note, I removed the coffee scripts and coded directly on the javascript files.

Current Tags

  • 0.2.1                                ...           latest (5 years ago)

1 Versions

  • 0.2.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 2
Dependencies (3)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2016 © taobao.org |