Add helper function to combine JSON strings as larger JSON file

This commit is contained in:
Veronica Berglyd Olsen
2025-10-05 17:13:40 +02:00
parent 04198f3ede
commit 0344701f1b
3 changed files with 23 additions and 6 deletions
+6
View File
@@ -560,6 +560,12 @@ def jsonEncode(data: dict | list | tuple, n: int = 0, nmax: int = 0) -> str:
return "".join(buffer)
def jsonCombine(data: dict[str, str]) -> str:
"""Combine multiple already packed JSON strings."""
payload = ",\n".join(f' "{k}": {v}' for k, v in data.items())
return f"{{\n{payload}\n}}\n"
##
# XML Helpers
##