@krisell/parser

1.0.3 • Public • Published

JSON parser wrapper

Simple wrapper for JSON.parse() with the option to set default data type, in case of parse error (e.g. empty string).

Installation

npm install @krisell/parser

How to use

Parser.json(stringifiedData) will return {} if stringifiedData can't be parsed, whereas Parser.json(stringifiedData, 'array') will return [].

The data and type settings can also be provided with an options object.

Parser.json({
    serialized: stringifiedData,
    type: 'array'
})

That's all there is to it.

Readme

Keywords

none

Package Sidebar

Install

npm i @krisell/parser

Weekly Downloads

17

Version

1.0.3

License

MIT

Unpacked Size

6.85 kB

Total Files

7

Last publish

Collaborators

  • krisell