Skip to content
This repository was archived by the owner on Apr 7, 2023. It is now read-only.

Repository files navigation

parse-object

Support parsing string contains object-liked syntax that can not be parsed by JSON.parse()

NPMJavaScript Style Guide

Sometimes, you receive string that has value like "{ sort: { date: 'DES' } }" and you want to parse it into an object. First solution would be, of course, JSON.parse(). However, your string is not valid JSON-formatted string so JSON.parse() will fail to parse it. That is the reason why I made this parse-object module.

Install

npm install --save parse-object

Usage

constparse=require('parse-object');conststr="{ sort: { date: 'DES' } }";console.log(parse(str));// { sort: { date: 'DES' }}console.log(JSON.parse(str));// raise error

parse-object can also parse any output from JSON.stringify()

constparse=require('parse-object');conststringified=JSON.stringify({name: "me",id: 123456});console.log(parse(stringified));// { name: "me", id: 123456 }

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages