@krisell/parser
v1.0.3
Published
Simple wrapper around JSON.parse for specifying default behaviour.
Downloads
312
Readme
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.
