https://github.com/idleberg/node-is-cson
Determines whether a string is valid CSON
https://github.com/idleberg/node-is-cson
coffeescript cson
Last synced: about 1 month ago
JSON representation
Determines whether a string is valid CSON
- Host: GitHub
- URL: https://github.com/idleberg/node-is-cson
- Owner: idleberg
- License: mit
- Created: 2019-05-25T21:24:58.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2023-12-28T11:58:02.000Z (over 1 year ago)
- Last Synced: 2025-04-09T01:53:21.488Z (about 2 months ago)
- Topics: coffeescript, cson
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/is-cson
- Size: 691 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# is-cson
> Determines whether a string is valid CSON
[](https://github.com/idleberg/node-is-cson/blob/main/LICENSE)
[](https://www.npmjs.org/package/is-cson)
[](https://github.com/idleberg/node-is-cson/actions)## Installation
`npm install is-cson -S`
## Usage
`isCSON(string, options?)`
**Example:**
```js
import { isCSON } from 'is-cson';// Generate CSON string
const csonString = `
firstName: 'John'
lastName: 'Doe'
`;isCSON(csonString);
// => true
```### Options
#### `allowJSON`
Default: `false`
Since CSON is a superset of *well-formatted* JSON, this library runs *strict* tests for CSON only. Enabling this option will also validate JSON, with CSON-specific features (such as trailing commas or single quotes) taking precedence.
Example
```js
const jsonString = `{
"firstName": "John",
"lastName": "Doe"
}`;isCSON(jsonString, { allowJSON: true });
// => true
```## License
This work is licensed under [The MIT License](https://opensource.org/licenses/MIT)