catch-json-parse

v0.0.1
JSON.parse in a try-catch with error handler
catch-json-parse json parse

catch-json-parse

#####JSON.parse in a try-catch with error handler


####Why?

I wanted to:

  • get rid of the try catch block in my code
  • be able to still use the catch as an error handler

--

parseJson= require( 'catch-json-parse' );

var json= JSON.stringify();

var errHandler= function( err ){
    console.log( err );
    //	[SyntaxError: Unexpected token u]
};

var obj= parseJSON( json, errHandler ) || {};

console.log( obj );
//	{}

###license

MIT

Metadata

  • GPL-3
  • Whatever
  • Dennis Raymondo van der Sluis
  • released 7/17/2016

Downloads

Maintainers