New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

graceful-json-parse

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graceful-json-parse

Parse your json safely and stop writing try {} catch {}

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by300%
Maintainers
1
Weekly downloads
 
Created
Source

Install

npm install graceful-json-parse

API

1、jsonParse(jsonString[, options])

Parameters
  • jsonString: The string to parse as JSON.
  • options(optional)
    • options.reviver: If a function, this prescribes how the value originally produced by parsing is transformed, before being returned. more info about this param in here
Return value

object {error, data}

  • error: should be an Error object in case of error or undefined in case of success
  • data: should be the object corresponding to the given JSON text or undefined in case of error
Example
const jsonParse = require("graceful-json-parse");

const result = jsonParse("{}");

2、jsonParse(jsonString[, options])

The parameters and return value is the same as above.

const jsonParse = require("graceful-json-parse/tuple");

const [error, data] = jsonParse("{}");

3、jsonParse(jsonString[, options], callback)

The parameters and return value is the same as above.

const jsonParse = require("graceful-json-parse/callback");

jsonParse("{}", function (error, data) {
  // your code
});

FAQs

Package last updated on 21 Jul 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc