I have a data set that looks like this:
{
"Stops": [
{
"Name": "COLUMBIA RD NW + MINTWOOD PL NW",
"Routes": [
"42",
"43",
"H1",
"L2"
]
}
]
}
And another that looks like this:
{
"Predictions": [
{
"DirectionText": "North to Mt Pleasant Via Adams Morgan",
"Minutes": 7,
"RouteID": "42"
},
{
"DirectionText": "North to Mt Pleasant Via Adams Morgan",
"Minutes": 25,
"RouteID": "42"
},
{
"DirectionText": "North to Chevy Chase Circle",
"Minutes": 32,
"RouteID": "L2"
},
{
"DirectionText": "North to Mt Pleasant Via Adams Morgan",
"Minutes": 36,
"RouteID": "42"
},
{
"DirectionText": "North to Mt Pleasant Via Adams Morgan",
"Minutes": 58,
"RouteID": "42"
},
{
"DirectionText": "North to Mt Pleasant Via Adams Morgan",
"Minutes": 69,
"RouteID": "42",
}
],
"StopName": "Columbia Rd Nw + Mintwood Pl Nw"
}
I'd like to combine the data on the Route ID in the first set, to add specifically the minutes to set. So the output would be something like:
{
"Stops": [
{
"Name": "COLUMBIA RD NW + MINTWOOD PL NW",
"Routes": [
{
"42": [
{
"Minutes": [7, 25,36,58,69]
}
],
"43": [
{
"Minutes": []
}
],
"H1":[
{
"Minutes": []
}
],
"L2": [
{
"Minutes": [32]
}
]
}
],
"StopID": "1001779"
}
]
}
I'm stuck with how to write some javascript/jquery that will do this merge. Any ideas?