diff --git a/_validate/createJson.py b/_validate/createJson.py index 5dd2b85..1701bc0 100644 --- a/_validate/createJson.py +++ b/_validate/createJson.py @@ -72,7 +72,18 @@ def generateJsonFile( filePath = buildOutputFilePath(data, parentDir) with open(filePath, "wt", encoding="utf-8") as f: - json.dump(dataclasses.asdict(data), f, indent="\t", ensure_ascii=False) + json.dump( + dataclasses.asdict( + data, + # The JSON schema does not permit null values, but does contain optional keys. + # # We have already ensured that all required keys are present in the metadata, + # So we can safely delete all keys whose value is None as optional. + dict_factory=lambda args: dict(filter(lambda item: item[1] is not None, args)), + ), + f, + indent="\t", + ensure_ascii=False, + ) print(f"Wrote json file: {filePath}")