1

次のような辞書の JSON リストがあります。

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\nSeven 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\nSeven 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
}]

データを上書きせずにこれらの辞書を組み合わせるにはどうすればよいですか?

したがって、私が取得しようとしている最終結果は次のとおりです。

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\nSeven 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
}

JSON オブジェクトのマージを調べましたが、データの上書きしか見つかりませんでした。何も上書きしたくありません。この問題にアプローチする方法がよくわかりません。

場所フィールドの空のリストを作成し、データセット全体を検索して同じタイトルを探し、それらの場所を取得して空のリストに追加し、最後に辞書を更新する必要がありますか? または、このようなことになると、より良い方法/ベストプラクティスはありますか?

4

2 に答える 2