CoffeeScript-Object-Notation. Same as JSON but for CoffeeScript objects.
Installations
npm install cson
Releases
Unable to fetch releases
Developer
bevry
Developer Guide
Module System
CommonJS
Min. Node Version
>=6
Typescript Support
No
Node Version
20.10.0
NPM Version
10.2.3
Statistics
1,336 Stars
205 Commits
56 Forks
24 Watching
7 Branches
13 Contributors
Updated on 10 Nov 2024
Languages
CoffeeScript (99.22%)
JavaScript (0.78%)
Total Downloads
Cumulative downloads
Total Downloads
38,089,009
Last day
-17.6%
11,961
Compared to previous day
Last week
-4.8%
82,773
Compared to previous week
Last month
1.5%
368,282
Compared to previous month
Last year
6.2%
4,136,663
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
4
CSON
CoffeeScript-Object-Notation. Same as JSON but for CoffeeScript objects.
Projects using CSON Parser directly.
Since v2, this CSON package is a higher-level wrapper around the lower-level CSON Parser.
What is CSON?
Everyone knows JSON, it's the thing that looks like this:
1{ 2 "greatDocumentaries": [ 3 "earthlings.com", 4 "forksoverknives.com", 5 "cowspiracy.com" 6 ], 7 "importantFacts": { 8 "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", 9 "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", 10 "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", 11 "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", 12 "more": "http://cowspiracy.com/facts" 13 } 14}
Now let's write the same thing in CSON:
1# Comments!!! 2 3# An Array with no commas! 4greatDocumentaries: [ 5 'earthlings.com' 6 'forksoverknives.com' 7 'cowspiracy.com' 8] 9 10# An Object without braces! 11importantFacts: 12 # Multi-Line Strings! Without Quote Escaping! 13 emissions: ''' 14 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. 15 Goodland, R Anhang, J. “Livestock and Climate Change: What if the key actors in climate change were pigs, chickens and cows?” 16 WorldWatch, November/December 2009. Worldwatch Institute, Washington, DC, USA. Pp. 10–19. 17 http://www.worldwatch.org/node/6294 18 ''' 19 20 landuse: ''' 21 Livestock covers 45% of the earth’s total land. 22 Thornton, Phillip, Mario Herrero, and Polly Ericksen. “Livestock and Climate Change.” Livestock Exchange, no. 3 (2011). 23 https://cgspace.cgiar.org/bitstream/handle/10568/10601/IssueBrief3.pdf 24 ''' 25 26 burger: ''' 27 One hamburger requires 660 gallons of water to produce – the equivalent of 2 months’ worth of showers. 28 Catanese, Christina. “Virtual Water, Real Impacts.” Greenversations: Official Blog of the U.S. EPA. 2012. 29 http://blog.epa.gov/healthywaters/2012/03/virtual-water-real-impacts-world-water-day-2012/ 30 “50 Ways to Save Your River.” Friends of the River. 31 http://www.friendsoftheriver.org/site/PageServer?pagename=50ways 32 ''' 33 34 milk: ''' 35 1,000 gallons of water are required to produce 1 gallon of milk. 36 “Water trivia facts.” United States Environmental Protection Agency. 37 http://water.epa.gov/learn/kids/drinkingwater/water_trivia_facts.cfm#_edn11 38 ''' 39 40 more: 'http://cowspiracy.com/facts'
Which is far more lenient than 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.
Using CSON
Via the Command Line
Use CSON with the command line with:
1# Convert a JSON file into a CSON file 2json2cson in.json > out.cson 3# Same thing via piping 4cat in.json | json2cson > out.cson 5 6# Convert a CSON file into a JSON file 7cson2json in.cson > out.json 8# Same thing via piping 9cat in.cson | cson2json > out.json
Requires a global CSON install: npm install -g cson
Via the API
Include CSON:
1var CSON = require('cson')
Each method can be executed without a callback like so:
1var result = CSON.createCSONString({a:{b:'c'}}, {/* optional options argument */}) 2if ( result instanceof Error ) { 3 console.log(result.stack) 4} else { 5 console.log(result) 6}
Or via a callback like so:
1CSON.createCSONString({a:{b:'c'}}, {/* optional options argument */}, function(err,result){ 2 console.log(err, result) 3})
Executing the method with a callback still executes the method synchronously.
Click the below function names to open more detailed documentation.
Create Strings
-
String CSON.stringify(data, replacer?, indent?)
Converts an Object into a CSON String -
String CSON.createCSONString(data, opts?, next?)
Converts an Object into a CSON String -
String CSON.createJSONString(data, opts?, next?)
Converts an Object into a JSON String -
String CSON.createString(data, opts?, next?)
Converts an Object into a String of the desired format If the format option is not specified, we default to CSON
Parse Strings
-
Object CSON.parse(data, opts?, next?)
Parses a CSON String into an Object -
Object CSON.parseCSONString(data, opts?, next?)
Parses a CSON String into an Object -
Object CSON.parseJSONString(data, opts?, next?)
Parses a JSON String into an Object -
Object CSON.parseCSString(data, opts?, next?)
Parses a CoffeeScript String into an Object -
Object CSON.parseJSString(data, opts?, next?)
Parses a JavaScript String into an Object -
Object CSON.parseString(data, opts?, next?)
Converts a String of the desired format into an Object If the format option is not specified, we default to CSON
Parse Files
-
Object CSON.load(filePath, opts?, next?)
Parses a CSON file into an Object -
Object CSON.parseCSONFile(filePath, opts?, next?)
Parses a CSON file into an Object -
Object CSON.parseJSONFile(filePath, opts?, next?)
Parses a JSON file into an Object -
Object CSON.parseCSFile(filePath, opts?, next?)
Parses a CoffeeScript file into an Object -
Object CSON.parseJSFile(filePath, opts?, next?)
Parses a JavaScript file into an Object -
Object CSON.parseFile(filePath, opts?, next?)
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
Require Files
-
Object CSON.requireCSFile(filePath, opts?, next?)
Requires a CoffeeScript file and returns the result Object -
Object CSON.requireJSFile(filePath, opts?, next?)
Requires a JavaScript file and returns the result Object -
Object CSON.requireFile(filePath, opts?, next?)
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 parsing CSON
Install
npm
Install Globally
- Install:
npm install --global cson
- Executables:
cson
,cson2json
,json2cson
Install Locally
- Install:
npm install --save cson
- Executables:
npx cson
,npx cson2json
,npx json2cson
- Import:
import * as pkg from ('cson')
- Require:
const pkg = require('cson')
Editions
This package is published with the following editions:
cson/source/index.coffee
is CoffeeScript source code with Require for modulescson
aliasescson/edition-esnext/index.js
cson/edition-esnext/index.js
is CoffeeScript compiled for Node.js 6 || 8 || 10 || 12 || 14 || 16 || 18 || 20 || 21 with Require for modules
History
Discover the release history by heading on over to the HISTORY.md
file.
Backers
Code
Discover how to contribute via the CONTRIBUTING.md
file.
Authors
- Benjamin Lupton — Accelerating collaborative wisdom.
Maintainers
- Benjamin Lupton — Accelerating collaborative wisdom.
Contributors
- Attila Oláh — view contributions
- Attila Oláh
- Benjamin Lupton — view contributions
- Claudius Nicolae — view contributions
- evinugur — view contributions
- Jason Karns — view contributions
- Joël Perras — view contributions
- Linus G Thiel — view contributions
- Rob Loach — view contributions
- Ryan LeFevre — view contributions
- Tushar Kant — view contributions
- Zearin — view contributions
- ZHANG Cheng — view contributions
Finances
Sponsors
- Andrew Nesbitt — Software engineer and researcher
- Balsa — We're Balsa, and we're building tools for builders.
- Codecov — Empower developers with tools to improve code quality and testing.
- Poonacha Medappa
- Rob Morris
- Sentry — Real-time crash reporting for your web apps, mobile apps, and games.
- Syntax — Syntax Podcast
Donors
- Andrew Nesbitt
- Armen Mkrtchian
- Balsa
- Chad
- Codecov
- dr.dimitru
- Elliott Ditman
- entroniq
- GitHub
- Hunter Beast
- Jean-Luc Geering
- Michael Duane Mooring
- Michael Harry Scepaniak
- Mohammed Shah
- Mr. Henry
- Nermal
- Pleo
- Poonacha Medappa
- Rob Morris
- Robert de Forest
- Sentry
- ServieJS
- Skunk Team
- Syntax
- WriterJohnBuck
License
Unless stated otherwise all works are:
- Copyright © Benjamin Lupton
and licensed under:
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
- Info: security policy file detected: SECURITY.md:1
- Info: Found linked content: SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1
- Info: Found text in security policy: SECURITY.md:1
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE.md:0
- Warn: project license file does not contain an FSF or OSI license.
Reason
1 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
Reason
SAST tool is not run on all commits -- score normalized to 2
Details
- Warn: 4 commits out of 18 are checked with a SAST tool
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: jobLevel 'contents' permission set to 'write': .github/workflows/bevry.yml:67
- Warn: no topLevel permission defined: .github/workflows/bevry.yml:1
Reason
Found 0/12 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/bevry.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/bevry/cson/bevry.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/bevry.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/bevry/cson/bevry.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/bevry.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/bevry/cson/bevry.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/bevry.yml:48: update your workflow using https://app.stepsecurity.io/secureworkflow/bevry/cson/bevry.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/bevry.yml:50: update your workflow using https://app.stepsecurity.io/secureworkflow/bevry/cson/bevry.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/bevry.yml:61: update your workflow using https://app.stepsecurity.io/secureworkflow/bevry/cson/bevry.yml/master?enable=pin
- Info: 0 out of 5 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
4.1
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More