I'm currently trying to learn the basics of javascript and working with JSON.
I have a JSON file wherein I want to combine the imports of the same name into one entry. How would that be possible?
Raw JSON
[{
"name": "1.date.17-Nov-18",
"size": 1000,
"imports": ["1.location.HOUSTON", "1.person.JOHN"]
},
{
"name": "1.date.17-Nov-18",
"size": 1000,
"imports": ["1.location.MIAMI", "1.person.BEN", "1.person.JOHN"]
},
{
"name": "1.date.18-Nov-18",
"size": 1000,
"imports": ["1.location.UBER", "1.person.JOHN"]
}
]
Expected output
[{
"name": "1.date.17-Nov-18",
"size": 1000,
"imports": ["1.location.HOUSTON", "1.person.JOHN", "1.location.MIAMI", "1.person.BEN"]
},
{
"name": "1.date.18-Nov-18",
"size": 1000,
"imports": ["1.location.UBER", "1.person.JOHN"]
}
]
Any tips and suggestions would be appreciated. Thank you very much.