Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cson

Package Overview
Dependencies
Maintainers
1
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cson

CoffeeScript-Object-Notation Parser. Same as JSON but for CoffeeScript objects

  • 1.4.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
46K
decreased by-10.92%
Maintainers
1
Weekly downloads
 
Created
Source

CSON

Check this project's build status on TravisCI View this project's NPM page Donate monthly to this project via Flattr Donate once-off to this project via Paypal

CoffeeScript-Object-Notation Parser. Same as JSON but for CoffeeScript objects.

What is CSON?

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:

{
	# an array
	abc: [
		'a'
		'b'
		'c'
	]

	# an object
	a:
		b: 'c'
}

Which is far more lenient than JSON, nicer to write and read, you don't have to quote everything, you have comments, and won't fail if you forget a comma.

Installing

  1. Install Node.js

  2. Install CSON

    npm install cson
    

Using CSON

  • With Node.js in JavaScript

    // Include CSON
    CSON = require('cson');
    
    // Parse a file path
    CSON.parseFile('data.cson', function(err,obj){});  // async
    result = CSON.parseFileSync('data.cson');  // sync
    
    // Parse a String
    CSON.parse(src, function(err,obj){});  // async
    result = CSON.parseSync(src);  // sync
    
    // Stringify an object to CSON
    CSON.stringify(obj, function(err,str){});  // async
    result = CSON.stringifySync(obj);  // sync
    
  • With Node.js in CoffeeScript

    # Include CSON
    CSON = require('cson')
    
    # Parse a file path
    CSON.parseFile 'data.cson', (err,obj) ->  # async
    result = CSON.parseFile('data.cson')  # sync
    
    # Parse a string
    CSON.parse src, (err,obj) ->  # async
    result = CSON.parseSync(src)  # sync
    
    # Stringify an object to CSON
    CSON.stringify data, (err,str) ->  # async
    result = CSON.stringifySync(obj)  # sync
    
    
    
  • Via the command line (requires a global installation of CSON via npm install -g cson)

    # JSON file to CSON String
    json2cson filePath > out.cson
    
    # CSON file to JSON String
    cson2json filePath > out.json
    

History

You can discover the version history inside the History.md file

License

Licensed under the incredibly permissive MIT License
Copyright © 2012+ Bevry Pty Ltd
Copyright © 2011 Benjamin Lupton

Keywords

FAQs

Package last updated on 30 Aug 2013

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc