Skip to content

Instantly share code, notes, and snippets.

@kazu69
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kazu69/9405825 to your computer and use it in GitHub Desktop.
Save kazu69/9405825 to your computer and use it in GitHub Desktop.
# cson to json
node_modules/cson/bin/cson2json data.cson
{"abc":["a","b","c"],"a":{"b":"c"}}
node_modules/cson/bin/json2cson data.json
{
abc: [
"a"
"b"
"c"
]
a:
b: "c"
}
# Include CSON
CSON = require('cson')
# Parse a file path
result = CSON.parseFileSync('data.cson') # sync
console.log result
// Include CSON
CSON = require('cson');
// Parse a file path
result = CSON.parseFileSync('data.cson'); // sync
console.log(result);
{
# an array
abc: [
'a'
'b'
'c'
]
# an object
a:
b: 'c'
}
{
"name": "try-cson",
"version": "0.0.1",
"description": "",
"dependencies": {
"cson": "^1.4.5"
}
}
# node
node cson.js
{ abc: [ 'a', 'b', 'c' ], a: { b: 'c' } }
# coffee
coffee cson.coffee
{ abc: [ 'a', 'b', 'c' ], a: { b: 'c' } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment