How do I remove duplicate interface {} on the basis of any element? like userid
"phonebook": [
{
"contact_id": 1,
"user_id": 13,
"userid": 2,
"username": "Tester"
},
{
"contact_id": 1,
"user_id": 13,
"userid": 2,
"username": "Tester"
},
{
"contact_id": 3,
"user_id": 13,
"userid": 22,
"username": "Tester"
}
]
1 Like
NobbZ
(Norbert Melzer)
2
I do not see even a single interface{}
, can you please elaborate on what you are after?
Sorry. I want to remove duplicate from array of hashes on basis of attributes i.e “userid”. For example
Input
"phonebook": [
{
"contact_id": 1,
"user_id": 13,
"userid": 2,
"username": "Tester"
},
{
"contact_id": 1,
"user_id": 13,
"userid": 2,
"username": "Tester"
},
{
"contact_id": 3,
"user_id": 13,
"userid": 22,
"username": "Tester"
}
]
***Required Output is: ***
"phonebook": [
{
"contact_id": 1,
"user_id": 13,
"userid": 2,
"username": "Tester"
},
{
"contact_id": 3,
"user_id": 13,
"userid": 22,
"username": "Tester"
}
]
skillian
(Sean Killian)
4
2 Likes
Thanks buddy for helping newbie on GOLang and I must appreciate the response time of the community.
system
(system)
Closed
6
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.