1.0.0 • Published 9 years ago
jsompile v1.0.0
What's this?
This tool converts js to json.
Some tools require json file for config file. However, json format disallow expressions and comments.
We can write config in js file with comments using this tool.
Example
const os = require("os")
module.exports = {
/*
We can use comment!
Double quotes of each key are unnecessary.
*/
a: 1,
b: {
c: "abc",
// Seconds per a day
// This way of writing is easy to change value.
d: 60 * 60 * 24,
},
// This should commented out when ****.
// e: false,
// Switch flag for each PC.
f: os.hostname() === "XXXXX",
}This file conveted as below:
{
"a": 1,
"b": {
"c": "abc",
"d": 86400
},
"f": false
}Usage
jsompile config.js --output config.jsonThe result is written to stdout if --ouput does not specified.
1.0.0
9 years ago