1.0.6 • Published 6 years ago

is-good-json v1.0.6

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

is-good-json

Simple package to validate JSON files.

npm Build Status Known Vulnerabilities npm Greenkeeper badge

npm.io

Usage

isGoodJSON('{"kity": "Fluffy"}'); // returns parsed object
isGoodJSON('{"kity" "Fluffy"}'); // returns false

Install / Update

npm install --save is-good-json

Usage

Syntax

isGoodJSON(<argument>);

Example

// load package
const isGoodJSON = require('is-good-json');

// use it
isGoodJSON('{"this": "is","a": "good json"}'); // -> returns parsed object: {"this": "is","a": "good json"}
isGoodJSON({ this: 'is', a: 'good json' }); // -> returns same object

isGoodJSON('{ha: "hi" meuo: "ho"}'); // -> returns false
isGoodJSON('[{"ths":asdf}{"adasd":asdf}]'); // -> returns false

// empty arrays and objects
isGoodJSON('[]'); // -> returns false
isGoodJSON('{}'); // -> returns false
isGoodJSON([]); // -> returns false
isGoodJSON({}); // -> returns false

Usage

Syntax : b = isGoodJSON(a);

where a and b are as follows,

value of avalue of b
nullfalse
true or falsefalse
any numberfalse
valid json as stringparsed json object
valid json as objectsame json object
invalid json as stringfalse
invalid json as objectfalse
valid, but empty jsonfalse
valid non-empty objectsame object
valid non-empty arraysame array
valid, but empty objectfalse
valid, but empty arrayfalse

one more example

isGoodJSON('{"name": "Kitty", "friends":["tom", "jerry"]}');
/* returns the following parsed object:
    {
        name: "kitty",
        friends: ["tom", "jerry"]
    }
 */

If you wish to file any feature/bugs, mention it on issues.

Enjoy.

Change log

  • v1.0.5, v1.0.6
    • linting stuffs
    • docs
    • greenkeeper issues
  • v1.0.4
    • Perf improvements with #1, (thanks @demacdonald)
    • adds Greenkeeper, tavis ci.
  • v1.0.3
    • Documentation updates.
  • v1.0.2
    • Dependency adjustments.
  • v1.0.1
    • Github integration done right.
  • v1.0.0
    • Initial release

License

MIT © Vajahath Ahmed

1.0.6

6 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago