idleberg / node-is-cson

Determines whether a string is valid CSON

Home Page:https://www.npmjs.com/package/is-cson

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

is-cson

Determines whether a string is valid CSON

License Version Build

Installation

npm install is-cson -S

Usage

isCSON(string, options?)

Example:

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
const jsonString = `{
  "firstName": "John",
  "lastName": "Doe"
}`;

isCSON(jsonString, { allowJSON: true });
// => true

License

This work is licensed under The MIT License

About

Determines whether a string is valid CSON

https://www.npmjs.com/package/is-cson

License:MIT License


Languages

Language:JavaScript 80.9%Language:TypeScript 18.0%Language:Shell 1.1%