Answer the question
In order to leave comments, you need to log in
How to remove duplicates in json list?
I have this json:
{
"items": [
{
"start_price": "3000",
"end_price": "2850",
"classid": "3106096757",
"instanceid": "338584038",
"name": "Souvenir MP5-SD | Lab Rats (Field-Tested)"
},
{
"start_price": "4500",
"end_price": "4275",
"classid": "3106142260",
"instanceid": "338584038",
"name": "Souvenir MP5-SD | Lab Rats (Field-Tested)"
},
{
"start_price": "5000",
"end_price": "4750",
"classid": "310781333",
"instanceid": "302028390",
"name": "P90 | Teardown (Field-Tested)"
}
]
}
{
"items": [
{
"start_price": "4500",
"end_price": "4275",
"classid": "3106142260",
"instanceid": "338584038",
"name": "Souvenir MP5-SD | Lab Rats (Field-Tested)"
},
{
"start_price": "5000",
"end_price": "4750",
"classid": "310781333",
"instanceid": "302028390",
"name": "P90 | Teardown (Field-Tested)"
}
]
}
Answer the question
In order to leave comments, you need to log in
input_data = {
"items": [
{
"start_price": "3000",
"end_price": "2850",
"classid": "3106096757",
"instanceid": "338584038",
"name": "Souvenir MP5-SD | Lab Rats (Field-Tested)"
},
{
"start_price": "4500",
"end_price": "4275",
"classid": "3106142260",
"instanceid": "338584038",
"name": "Souvenir MP5-SD | Lab Rats (Field-Tested)"
},
{
"start_price": "5000",
"end_price": "4750",
"classid": "310781333",
"instanceid": "302028390",
"name": "P90 | Teardown (Field-Tested)"
}
]
}
output_data = [v for v in {inp['name']: inp for inp in input_data['items']}.values()]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question