I have a project where I have to take some data from a GoogleSheet document and send it to database. I get the data from googlesheet document, but the problem is how is the data structured.
[
{
class: "A",
name: "Alex",
age: 13
},
{
class: "A",
name: "Mary",
age: 14
},
{
class: "B",
name: "John",
age: 13
},
{
class: "B",
name: "William",
age: 12
}
]
The problem is I want my JSON object to look like this
[
"A": {
{
name: "Alex",
age: 13
},
{
name: "Mary",
age: 13
}
},
"B": {
{
name: "John",
age: 13
},
{
name: "William",
age: 13
}
}
]
Any idea how can I do that? I want to group my objects over an element, like the class. All the people with the same class value to be in the same group/json.
Array.prototype.reducefunction?{"A":[{"name":"Alex","age":13},{"name":"Mary","age":14}]}