Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
CoffeeScript-Object-Notation. Same as JSON but for CoffeeScript objects.
Projects using CSON Parser directly.
require('cson')
npm install --save cson
Everyone knows JSON, it's the thing that looks like this:
{
"greatDocumentaries": [
"earthlings.com",
"forksoverknives.com",
"cowspiracy.com"
],
"importantFacts": {
"emissions": "Livestock and their byproducts account for at least 32,000 million tons of carbon dioxide (CO2) per year, or 51% of all worldwide greenhouse gas emissions.\nGoodland, R Anhang, J. “Livestock and Climate Change: What if the key actors in climate change were pigs, chickens and cows?”\nWorldWatch, November/December 2009. Worldwatch Institute, Washington, DC, USA. Pp. 10–19.\nhttp://www.worldwatch.org/node/6294",
"landuse": "Livestock covers 45% of the earth’s total land.\nThornton, Phillip, Mario Herrero, and Polly Ericksen. “Livestock and Climate Change.” Livestock Exchange, no. 3 (2011).\nhttps://cgspace.cgiar.org/bitstream/handle/10568/10601/IssueBrief3.pdf",
"burger": "One hamburger requires 660 gallons of water to produce – the equivalent of 2 months’ worth of showers.\nCatanese, Christina. “Virtual Water, Real Impacts.” Greenversations: Official Blog of the U.S. EPA. 2012.\nhttp://blog.epa.gov/healthywaters/2012/03/virtual-water-real-impacts-world-water-day-2012/\n“50 Ways to Save Your River.” Friends of the River.\nhttp://www.friendsoftheriver.org/site/PageServer?pagename=50ways",
"milk": "1,000 gallons of water are required to produce 1 gallon of milk.\n“Water trivia facts.” United States Environmental Protection Agency.\nhttp://water.epa.gov/learn/kids/drinkingwater/water_trivia_facts.cfm#_edn11",
"more": "http://cowspiracy.com/facts"
}
}
Now let's write the same thing in CSON:
# Look Ma! Comments!!!
# Look Ma! An Array with no commas!
greatDocumentaries: [
'earthlings.com'
'forksoverknives.com'
'cowspiracy.com'
]
# Look Ma! An Object without braces!
importantFacts:
# Look Ma! Multi-Line Strings! Without Quote Escaping!
emissions: '''
Livestock and their byproducts account for at least 32,000 million tons of carbon dioxide (CO2) per year, or 51% of all worldwide greenhouse gas emissions.
Goodland, R Anhang, J. “Livestock and Climate Change: What if the key actors in climate change were pigs, chickens and cows?”
WorldWatch, November/December 2009. Worldwatch Institute, Washington, DC, USA. Pp. 10–19.
http://www.worldwatch.org/node/6294
'''
landuse: '''
Livestock covers 45% of the earth’s total land.
Thornton, Phillip, Mario Herrero, and Polly Ericksen. “Livestock and Climate Change.” Livestock Exchange, no. 3 (2011).
https://cgspace.cgiar.org/bitstream/handle/10568/10601/IssueBrief3.pdf
'''
burger: '''
One hamburger requires 660 gallons of water to produce – the equivalent of 2 months’ worth of showers.
Catanese, Christina. “Virtual Water, Real Impacts.” Greenversations: Official Blog of the U.S. EPA. 2012.
http://blog.epa.gov/healthywaters/2012/03/virtual-water-real-impacts-world-water-day-2012/
“50 Ways to Save Your River.” Friends of the River.
http://www.friendsoftheriver.org/site/PageServer?pagename=50ways
'''
milk: '''
1,000 gallons of water are required to produce 1 gallon of milk.
“Water trivia facts.” United States Environmental Protection Agency.
http://water.epa.gov/learn/kids/drinkingwater/water_trivia_facts.cfm#_edn11
'''
more: 'http://cowspiracy.com/facts'
Which is far more lenient that JSON, way nicer to write and read, no need to quote and escape everything, has comments and readable multi-line strings, and won't fail if you forget a comma.
Use CSON with the command line with:
# Convert a JSON file into a CSON file
json2cson in.json > out.cson
# Same thing via piping
cat in.json | json2cson > out.cson
# Convert a CSON file into a JSON file
cson2json in.cson > out.json
# Same thing via piping
cat in.cson | cson2json > out.json
Requires a global CSON install: npm install -g cson
// Prepare
var CSON = require('cson')
var result = null
// Create a CSON string
result = CSON.stringify(object)
if ( result instanceof Error ) {
console.log(result.stack)
} else {
console.log(result)
}
// Parse a CSON string
result = CSON.parse(object)
if ( result instanceof Error ) {
console.log(result.stack)
} else {
console.log(result)
}
// Load a CSON file
result = CSON.load(filePath)
if ( result instanceof Error ) {
console.log(result.stack)
} else {
console.log(result)
}
// Require a configuration file
result = CSON.requireFile(filePath, {
cson: true, // support CSON files (default is true)
json: true, // support JSON files (default is true)
coffeescript: false, // support CSON files (default is false)
javascript: false // support CSON files (default is false)
})
if ( result instanceof Error ) {
console.log(result.stack)
} else {
console.log(result)
}
// Parse/Load a configuration file
result = CSON.parseFile(filePath, {
cson: true, // support CSON files (default is true)
json: true, // support JSON files (default is true)
coffeescript: false, // support CSON files (default is false)
javascript: false // support CSON files (default is false)
})
if ( result instanceof Error ) {
console.log(result.stack)
} else {
console.log(result)
}
Click the function names for more details on how the specific function operates including the options it supports.
String ::stringify(data, opts)
Converts an Object into a String of the desired format If the format option is not specified, we default to CSON
String ::createString(data, opts)
Converts an Object into a String of the desired format If the format option is not specified, we default to CSON
String ::createCSONString(data, opts)
Converts an Object into a CSON String
String ::createJSONString(data, opts)
Converts an Object into a JSON String
Object ::parse(data, opts)
Converts a String of the desired format into an Object If the format option is not specified, we default to CSON
Object ::parseString(data, opts)
Converts a String of the desired format into an Object If the format option is not specified, we default to CSON
Object ::parseCSONString(data, opts)
Parses a CSON String into an Object
Object ::parseJSONString(data, opts)
Parses a JSON String into an Object
Object ::parseCSString(data, opts)
Parses a CoffeeScript String into an Object
Object ::parseJSString(data, opts)
Parses a JavaScript String into an Object
Object ::load(data, opts)
Parses a file path of the desired format into an Object If the format option is not specified, we use the filename to detect what it should be, otherwise we default to CSON
Object ::parseFile(data, opts)
Parses a file path of the desired format into an Object If the format option is not specified, we use the filename to detect what it should be, otherwise we default to CSON
Object ::parseCSONFile(file, opts)
Parses a CSON file into an Object
Object ::parseJSONFile(file, opts)
Parses a JSON file into an Object
Object ::parseCSFile(file, opts)
Parses a CoffeeScript file into an Object
Object ::parseJSFile(file, opts)
Parses a JAvaScript file into an Object
Object ::require(data, opts)
Requires or parses a file path of the desired format into an Object If the format option is not specified, we use the filename to detect what it should be, otherwise we default to CSON
Object ::requireFile(data, opts)
Requires or parses a file path of the desired format into an Object If the format option is not specified, we use the filename to detect what it should be, otherwise we default to CSON
Object ::requireCSONFile(file, opts)
Parses a CSON file into an Object
Object ::requireJSONFile(file, opts)
Parses a JSON file into an Object
Object ::requireCSFile(file, opts)
Requires a CoffeeScript file and returns the result Object
Object ::requireJSFile(file, opts)
Requires a JavaScript file and returns the result Object
Discover the change history by heading on over to the HISTORY.md
file.
Discover how you can contribute by heading on over to the CONTRIBUTING.md
file.
These amazing people are maintaining this project:
No sponsors yet! Will you be the first?
These amazing people have contributed code to this project:
Licensed under the incredibly permissive MIT license
Copyright © 2012+ Bevry Pty Ltd us@bevry.me (http://bevry.me)
Copyright © 2011 Benjamin Lupton b@lupton.cc (http://balupton.com)
v2.0.0 2015 February 6
FAQs
CoffeeScript-Object-Notation Parser. Same as JSON but for CoffeeScript objects.
The npm package cson receives a total of 52,465 weekly downloads. As such, cson popularity was classified as popular.
We found that cson demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.