项目作者: idleberg

项目描述 :
Determines whether a string is valid CSON
高级语言: JavaScript
项目地址: git://github.com/idleberg/node-is-cson.git
创建时间: 2019-05-25T21:24:58Z
项目社区:https://github.com/idleberg/node-is-cson

开源协议:MIT License

下载


is-cson

Determines whether a string is valid CSON

License
Version
Build

Installation

npm install is-cson -S

Usage

isCSON(string, options?)

Example:

  1. import { isCSON } from 'is-cson';
  2. // Generate CSON string
  3. const csonString = `
  4. firstName: 'John'
  5. lastName: 'Doe'
  6. `;
  7. isCSON(csonString);
  8. // => 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