Skip to content

radiovisual/happy-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

happy-json 😃

Build Status

Check if your string or object is valid JSON, or could happily be valid JSON. 😃

This is not a strict JSON validator (although it sort of behaves like one). If you simply want strict JSON validation, then there are other modules out there. What this module does is check if your object or string is valid or could be valid JSON, because sometimes your application wants to know these things in order for it to be truly happy. 😃

Install

$ npm install --save happy-json

Usage

const happyAsJSON = require('happy-json');

// valid json objects
happyAsJSON({"happy": "json"});
//=> true

// valid json strings
happyAsJSON(JSON.stringify({happy: 'json'}));
//=> true

// objects that could [happily] be json
happyAsJSON({happy: 'json'});
//=> true

// rejects anything that isn't json
// or anything that couldn't be valid json
happyAsJSON('unicorns');
//=> false

Take a look at the tests for more usage examples.

API

happyJson(input)

Returns true or false

input

Type: string|object

The string or object that you want to validate as JSON, or check to see if it could be valid JSON.

License

MIT © Michael Wuergler

About

Check if your string or object is (or could happily be) valid JSON. 😄

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published