Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion _validate/createJson.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")


Expand Down
Loading