包详细信息

@madhavanand/object-string-to-object

Converts/Parses the JavaScript Object in String Type to JavaScript Object.

JavaScript Object, Object Conversion, String to Object, Object Parsing

自述文件

JS Object String to JS Object

A npm package that converts/parses the JavaScript Object in String Type to JavaScript Object.

Input : JavaScript Object as String Type
Output : JavaScript Object

The Problem

image

Example

Object Strings Failed to parse

const objString = "{ url : 'http://google.com' }"
const objString = "{ 'url' : 'http://google.com' }"

image

How to use


// Import
const customParser = require('object-string-to-object')  

// Test String
const objString = '{ url : "http://google.com" }';  

// Output
const result = customParser(objString);

For a correct input, output is 100% correct.
For an incorrect input, you may get an undesired output/error.
For an Error, null is returned.