How to convert string
"{7: {type: 'line'},8: {type: 'line'}}"
into JavasScript OBJECT
{7: {type: 'line'},8: {type: 'line'}}
How to convert string
"{7: {type: 'line'},8: {type: 'line'}}"
into JavasScript OBJECT
{7: {type: 'line'},8: {type: 'line'}}
Use JSON.parse
JSON.parse(STRING) // convert to object
JSON.stringify(STRING) // convert object to string, that can be used in JSON.parse
Don't use numbers as keys, because it bad practice you can't access objects like this:
var a = {"8": "value"};
// Invalid syntax
console.log(a.8)
// work
console.log(a["8"], a[8]);
var b = {"eight" : "value"};
// work
console.log(b.eight);