is-valid-json

1.0.2 • Public • Published

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
}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    2,752
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    2,752
  • 1.0.1
    1
  • 1.0.0
    1

Package Sidebar

Install

npm i is-valid-json

Weekly Downloads

2,754

Version

1.0.2

License

MIT

Last publish

Collaborators

  • shubhamoli