cson-parser

WebJar for cson-parser

License

License

BSD 3-Clause
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

cson-parser
Last Version

Last Version

1.3.5
Release Date

Release Date

Type

Type

jar
Description

Description

cson-parser
WebJar for cson-parser
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/groupon/cson-parser

Download cson-parser

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/cson-parser/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>cson-parser</artifactId>
    <version>1.3.5</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/cson-parser/
implementation 'org.webjars.npm:cson-parser:1.3.5'
// https://jarcasting.com/artifacts/org.webjars.npm/cson-parser/
implementation ("org.webjars.npm:cson-parser:1.3.5")
'org.webjars.npm:cson-parser:jar:1.3.5'
<dependency org="org.webjars.npm" name="cson-parser" rev="1.3.5">
  <artifact name="cson-parser" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='cson-parser', version='1.3.5')
)
libraryDependencies += "org.webjars.npm" % "cson-parser" % "1.3.5"
[org.webjars.npm/cson-parser "1.3.5"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : coffee-script jar [1.10.0,2)

Project Modules

There are no modules declared in this project.

nlm-github nlm-node nlm-version

cson-parser

A minimalistic CSON parser. Offers:

  • A strict subset of CSON that allows only data
  • Interface is identical to JSON.{parse,stringify}
  • Does not run the code, free of intermediate string representations
  • Sane parse error messages with line/column
  • Regular Expressions are considered data and will be accepted as well

In addition of pure data it allows for simple arithmetic expressions like addition and multiplication. This allows more readable configuration of numbers, the following is a valid strict CSON file:

cachedData:
  refreshIntervalMs: 5 * 60 * 1000

Install

npm install --save cson-parser

Usage

CSON = require 'cson-parser'
# This will print { a: '123' }
console.log CSON.parse "a: '123'"

High-level APIs

cson-parser only offers basic parsing and serialization. But there are some great tools if you want more than that:

  • fs-cson, read and write CSON files
  • CSON, provides file, coffeescript, javascript handling and a CLI
  • season, atom.io's CSON package. Includes CLI tool to convert CSON to JSON
  • grunt-cson, converts CSON to JSON as a grunt task
  • load-grunt-configs, loads grunt config from CSON files (among other formats)
  • fetcher, a declarative way to download (frontend) libraries, supports CSON configs
  • csonschema, parses JSON Schema files written in CSON

You can find more on the npm website.

FAQ

Why not just use YAML?

YAML allows for some pretty complex constructs like anchor and alias, which can behave in unexpected ways, especially with nested objects. CSON is simpler while still offering most of the niceties of YAML.

Why not just use JSON?

JSON doesn't offer multi-line strings and is generally a little noisier. Also sometimes it can be nice to have comments in config files.

Why not just use CoffeeScript directly?

You don't want data files being able to run arbitrary code. Even when ran in a proper sandbox, while(true) is still possible.

org.webjars.npm

Groupon

Versions

Version
1.3.5