str-to-obj

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

Usage no npm install needed!

<script type="module">
  import strToObj from 'https://cdn.skypack.dev/str-to-obj';
</script>

README

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'
}