Update json_to_tree.py

This commit is contained in:
2026-01-22 04:24:24 +01:00
parent c8cf9b4d75
commit a5cb0f81cb
+5 -3
View File
@@ -9,17 +9,19 @@ def build_tree(data, tree):
if isinstance(data, dict):
for key, value in data.items():
if isinstance(value, (dict, list)):
branch = tree.add(f"{key}")
branch = tree.add(f"[bold]{key}[/bold]")
build_tree(value, branch)
else:
tree.add(f"{key}: {value}")
safe_value = str(value).replace("[", "\\[").replace("]", "\\]")
tree.add(f"{key}: {safe_value}")
elif isinstance(data, list):
for value in data:
if isinstance(value, (dict, list)):
branch = tree.add("-")
build_tree(value, branch)
else:
tree.add(f"{value}")
safe_value = str(value).replace("[", "\\[").replace("]", "\\]")
tree.add(f"{safe_value}")
def main():
file_path = sys.argv[1]