I have a JSON list of dictionaries like so:
data = [{
"title": "Bullitt",
"release_year": "1968",
"locations": "1153-57 Taylor Street",
"fun_facts": "Embarcadero Freeway, which was featured in the film was demolished in 1989 because of structural damage from the 1989 Loma Prieta Earthquake)",
"production_company": "Warner Brothers / Seven Arts
Seven Arts",
"distributor": "Warner Brothers",
"director": "Peter Yates",
"writer": "Alan R. Trustman",
"actor_1": "Steve McQueen",
"actor_2": "Jacqueline Bisset",
"actor_3": "Robert Vaughn",
"id": 498
},
{
"title": "Bullitt",
"release_year": "1968",
"locations": "John Muir Drive (Lake Merced)",
"production_company": "Warner Brothers / Seven Arts
Seven Arts",
"distributor": "Warner Brothers",
"director": "Peter Yates",
"writer": "Alan R. Trustman",
"actor_1": "Steve McQueen",
"actor_2": "Jacqueline Bisset",
"actor_3": "Robert Vaughn",
"id": 499
}]
How do I combine these dictionaries without overwriting the data?
So, the final result which I am trying to get is:
data = {
"title": "Bullitt",
"release_year": "1968",
"locations": ["1153-57 Taylor Street", "John Muir Drive (Lake Merced)"]
"fun_facts": "Embarcadero Freeway, which was featured in the film was demolished in 1989 because of structural damage from the 1989 Loma Prieta Earthquake)",
"production_company": "Warner Brothers / Seven Arts
Seven Arts",
"distributor": "Warner Brothers",
"director": "Peter Yates",
"writer": "Alan R. Trustman",
"actor_1": "Steve McQueen",
"actor_2": "Jacqueline Bisset",
"actor_3": "Robert Vaughn",
"id": 498, 499
}
I looked into merging JSON objects but all I came across was overwriting data. I do not want to overwrite anything. Not really sure how to approach this problem.
Would I have to make an empty list for the locations field and search through the entire data set looking for titles that are the same and take their locations and append them to the empty list and then finally update the dictionary? Or is there a better way/best practice when it comes to something like this?