import json with open("fixtures/merger.json", "r") as f: data = json.load(f) db = data[0]["database"] # Add organization_id to fields and grouped_fields.entity of order, order_line, person for t in db["types"]: if t["name"] in ["order", "order_line", "person"]: if "organization_id" not in t["fields"]: t["fields"].append("organization_id") if "organization_id" not in t["grouped_fields"]["entity"]: t["grouped_fields"]["entity"].append("organization_id") with open("fixtures/merger.json", "w") as f: json.dump(data, f, indent=2)