Sorting lists before diffing helps, because the list order is not kept guaranteed by the UI/API (?) but - although technicaly it matters in JSON - it should be irrelevant for our records. This hardodes some properties and therefore overfits.
17 lines
495 B
Python
17 lines
495 B
Python
from argparse import ArgumentParser
|
|
from pathlib import Path
|
|
import json
|
|
|
|
parser = ArgumentParser()
|
|
parser.add_argument("infile", type=Path)
|
|
parser.add_argument("outfile", type=Path)
|
|
args = parser.parse_args()
|
|
|
|
with args.infile.open("rb") as fp:
|
|
d = json.load(fp)
|
|
|
|
d["associated_with"] = sorted(d["associated_with"], key = lambda x: x["object"])
|
|
d["influenced_by"] = sorted(d["influenced_by"], key = lambda x: x["object"])
|
|
|
|
with args.outfile.open("wt") as fp:
|
|
json.dump(d, fp, indent=4)
|