I'm currently learning about underscore and came across a task that I could use some assistance with. I have an array containing objects like the following:
[
// ...
{
"type": "presence",
"params": {
"interval": 15,
"foo": "something",
"link": {
"fp_type": "1",
"fp_ext_id": "2"
},
},
{
"type": "bar",
"params": {
"interval": 30,
"foo": "foo",
"link": {
"fp_type": "2",
"fp_ext_id": "3"
},
},
},
// ...
]
The task at hand requires using underscore to convert these array items into an object where the key is the item's type and the value is its parameters, as shown below:
{
// ...
"presence": {
"interval": 15,
"foo": "something",
"link": {
"fp_type": "1",
"fp_ext_id": "2"
},
},
"bar": {
"interval": 30,
"foo": "foo",
"link": {
"fp_type": "2",
"fp_ext_id": "3"
},
// ...
}