I’m parsing some json made from a midi file (I’ll be doing this a lot for a game I’m making) and I an easy way to do it using Lodash.
I’ve tried .groupBy and .filter and a couple other methods, they aren’t working
This is what I want to go from:
{
"name": "F4",
"midi": 65,
"time": 0,
"velocity": 1,
"duration": 0.8
},
{
"name": "C5",
"midi": 72,
"time": 0,
"velocity": 1,
"duration": 0.8
},
{
"name": "C#4",
"midi": 61,
"time": 0.8,
"velocity": 1,
"duration": 0.8
},
{
"name": "F4",
"midi": 65,
"time": 0.8,
"velocity": 1,
"duration": 0.8
},
{
"name": "C5",
"midi": 72,
"time": 0.8,
"velocity": 1,
"duration": 0.8
}
And this is what I’m trying to get as an output:
{
"notes": ["F4","C5"],
"time": 0,
"volume": 1,
"duration": 0.8
},
{
"notes": ["C#4","F4","C5"],
"time": 0.8,
"volume": 1,
"duration": 0.8
},
The "notes" are condensed into an array based on the "time" value.