CoffeeScript-Object-Notation Parser. Same as JSON but for CoffeeScript objects.
Everyone knows JSON, it's the thing that looks like this:
{
"abc": [
"a",
"b",
"c"
],
"a": {
"b": "c"
}
}
But with the invention of CoffeeScript you can also write the same thing in CSON which looks like this:
{
abc: [
'a'
'b'
'c'
]
a:
b: 'c'
}
Which is far more leniant than JSON, nicer to write and read, and won't fail if you forget a comma.
-
Install CSON
npm install cson
-
With Node.js in JavaScript
// Include CSON require('coffee-script'); CSON = require('cson'); // Parse a file CSON.parseFile('data.cson', function(err,obj){}); // Parse a string CSON.parse(dataStr, function(err,obj){}); // Stringify an object CSON.stringify(data, function(err,str){});
-
With Node.js in CoffeeScript
# Include CSON CSON = require 'cson' # Parse a file CSON.parseFile 'data.cson', (err,obj) -> # Parse a string CSON.parse dataStr, (err,obj) -> # Stringify an object CSON.stringify data, (err,str) ->
To learn more about CSON visit its wiki here
-
v0.2 August 10, 2011
-
v0.1 June 2, 2011
- Initial commit
Licensed under the MIT License Copyright 2011 Benjamin Arthur Lupton