1.0.2 • Published 8 years ago

is-valid-json v1.0.2

Weekly downloads
1,016
License
MIT
Repository
github
Last release
8 years ago

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
}