Is this a good way of converting Array to Object?
let y = JSON.stringify([{'name': 'ben', 'age': 30}]);
let lb = JSON.parse(y.slice(1, y.length - 1));
console.log(typeof y, typeof lb);
from the comments
From
[{'name': 'ben', 'age': 30},{'name': 'john', 'age': 25}]
to
{ben: {'name': 'ben', 'age': 30}, john: {'name': 'john', 'age': 25}}