How do I group a json according to a field?
I have the following json:
{
"origem": [
{
"id": 154826,
"nm": "",
"tp": "",
"am": "",
"sg": "SAO",
"sq": 925
},
{
"id": 2289,
"nm": "",
"tp": "",
"am": "",
"sg": "RIO",
"sq": 925
},
{
"id": 154826,
"nm": "",
"tp": "",
"am": "",
"sg": "SAO",
"sq": 925
}
]
}
I wanted to group it according to the id so it looks like this:
{
"origem": [
{
"id": 154826,
"nm": "",
"tp": "",
"am": "",
"sg": "SAO",
"sq": 925
},
{
"id": 2289,
"nm": "",
"tp": "",
"am": "",
"sg": "RIO",
"sq": 925
}
]
}
In case it would be more remove the repeated items. Does anyone know how to do this?