JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 17
  • Score
    100M100P100Q54130F
  • License MIT

Try to parse a string as JSON and return undefined on failure

Package Exports

  • tryjson

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tryjson) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node tryjson

tryjson

Build Status Coverage Status

This module works like JSON.parse (and in fact it uses JSON.parse) but instead of throwing exceptions it returns undefined on failure. This is not always a desired behaviour but sometimes it is.

This is still work in progress.

Installation

Install to use in your Node project, updating the dependencies in package.json:

npm install tryjson --save

Examples

Basic usage:

var tryjson = require('tryjson');

console.log(tryjson.parse('{"a":1,"b":2}'));
// { a: 1, b: 2 }

console.log(tryjson.parse('{"a":1,"b":2'));
// undefined

Issues

For any bug reports or feature requests please post an issue on GitHub.

Author

Rafał Pocztarski - https://github.com/rsp

License

MIT License (Expat). See LICENSE.md for details.