/str-to-obj

Get an object from a string which is separated by some endpoints

Primary LanguageJavaScript

str-to-obj

Get an object from a string which is separated by some endpoints

Example

Code

const stringToObject = require('str-to-obj');

const queryString = 'type:car,color:blue,year:2005';
const myObject = stringToObject(queryString, ',', ':');

console.log(myObject);

Result

{
    type: 'car',
    color: 'blue',
    year: '2005'
}