Original Post = Remove duplicates from json data
This is only my second post. I didnt have enough points to comment my question on the original post...So here I am.
Andy Hayden makes a great point - "Also, those aren't really duplicates... – Andy Hayden"
My question is just that situation... How can you remove duplicates from a json file but by matching against more than 1 key in the json file?
Here is the original example: (it was pointed out that it is not a valid json)
{
{obj_id: 123,
location: {
x: 123,
y: 323,
},
{obj_id: 13,
location: {
x: 23,
y: 333,
},
{obj_id: 123,
location: {
x: 122,
y: 133,
},
}
My case is very similar to this example except In my case, it would keep all these because the x and y values of obj_id are unique, however if x and y were the same than one would be removed from json file.
All the examples I have found only kick out ones based on only one key match..
I don't know if it matters, but the keys that I need to match against are "Company Name" , "First Name", and "Last Name" (it is a 100k plus line json of companies and contacts - there are times when the same person is a contact of multiple companies which is why I need to match against multiple keys)
Thanks.
json.load()orjson.loads()to return one that has has values with duplicate keys. It's one of the differences between Python dictionaries and JSON objects. Would getting alistof the objects be useful, because that might be possible.arrays(orlistsin Python), that can have duplicates... consider:json.loads("[1,2,3,1,1]")list(aka JSON array) would be acceptable to them in my comment.