Last active
August 29, 2015 13:57
-
-
Save kazu69/9406422 to your computer and use it in GitHub Desktop.
try json5 https://github.com/aseemk/json5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules/json5/lib/cli.js -c data.json5 | |
cat data.json | |
{ | |
"foo": "bar", | |
"while": true, | |
"this": "is a multi-line string", | |
"here": "is another", | |
"hex": 3735928559, | |
"half": 0.5, | |
"delta": 10, | |
"to": null, | |
"finally": "a trailing comma", | |
"oh": [ | |
"we shouldn't forget", | |
"arrays can have", | |
"trailing commas too" | |
] | |
}% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
foo: 'bar', | |
while: true, | |
this: 'is a \ | |
multi-line string', | |
// this is an inline comment | |
here: 'is another', // inline comment | |
/* this is a block comment | |
that continues on another line */ | |
hex: 0xDEADbeef, | |
half: .5, | |
delta: +10, | |
to: Infinity, // and beyond! | |
finally: 'a trailing comma', | |
oh: [ | |
"we shouldn't forget", | |
'arrays can have', | |
'trailing commas too', | |
], | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// json5 をrequireできるようにする | |
require('json5/lib/require'); | |
var JSON5 = require('json5'); | |
var data = require('./data'); | |
result = JSON5.stringify(data); | |
console.log(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node json5.js | |
{foo:"bar",while:true,this:"is a multi-line string",here:"is another",hex:3735928559,half:0.5,delta:10,to:null,finally:"a trailing comma",oh:["we shouldn't forget","arrays can have","trailing commas too"]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment