jsu

jsun

Error catching JSON methods. Hides away the try/catch madness for parsing strings and stringifying JSON objects.

Showing:

Popularity

Downloads/wk

1

GitHub Stars

1

Maintenance

Last Commit

8yrs ago

Contributors

0

Package

Dependencies

0

Size (min+gzip)

0.2KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

jsun

Error catching JSON methods.

Hides away the try/catch madness for parsing strings and stringifying JSON objects.

Install

npm install jsun --save

Usage

var JSUN = require('jsun');

var validStr = JSUN.stringify({key: 'value'}).string;
var invalidStr = '<div></div>';

var validData = JSUN.parse(validStr);
console.log(validData.json) // {key: 'value'}
console.log(validData.err) // null

var invalidData = JSUN.parse(invalidStr);
console.log(invalidData.json) // null
console.log(invalidData.err) // error message from try/catch

Methods

parse(string)

Uses JSON.parse in a try/catch block

Returns:

{
  json: {} // some parsed string
  err: null // not null if there is an error
}

stringify(object)

Uses JSON.stringify in a try/catch block

Returns:

{
  string: {} // some stringified object
  err: null // not null if there is an error
}

Run Tests

npm install
npm test

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100