is-valid-json
v1.0.2
Published
A small tool to check if a Javscript literal/object is JSON or not
Downloads
10,814
Maintainers
Readme
is-valid-json
A small tool to check if a Javscript literal/object is JSON or not
Installation (as node package)
npm install is-valid-json --save
Version
1.0.2
License
MIT
Usage
var isJSON = require('is-valid-json');
// "obj" can be {},{"foo":"bar"},2,"2",true,false,null,undefined, etc.
var obj = "any JS literal here";
if( isJSON(obj) ){
// Valid JSON, do something
}
else{
// not a valid JSON, show friendly error message
}