is-good-json
Simple package to validate JSON files.
Usage
; // returns parsed object; // returns false
Install / Update
npm install --save is-good-json
Usage
Syntax
isGoodJSON(<argument>);
Example
// load packageconst isGoodJSON = ; // use it; // -> returns parsed object: {"this": "is","a": "good json"}; // -> returns same object ; // -> returns false; // -> returns false // empty arrays and objects; // -> returns false; // -> returns false; // -> returns false; // -> returns false
Usage
Syntax : b = isGoodJSON(a);
where a
and b
are as follows,
value of a |
value of b |
---|---|
null |
false |
true or false |
false |
any number | false |
valid json as string |
parsed json object |
valid json as object |
same json object |
invalid json as string |
false |
invalid json as object |
false |
valid, but empty json | false |
valid non-empty object |
same object |
valid non-empty array |
same array |
valid, but empty object |
false |
valid, but empty array |
false |
one more example
;/* 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