Socket
Socket
Sign inDemoInstall

catch-json-parse

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    catch-json-parse

JSON.parse in a try-catch with error handler


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
3.69 kB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 13 Sep 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc