From a5cb0f81cb14efcb4dab71c55312fdebbbb9fd6c Mon Sep 17 00:00:00 2001 From: tligui_y Date: Thu, 22 Jan 2026 04:24:24 +0100 Subject: [PATCH] Update json_to_tree.py --- json_to_tree.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/json_to_tree.py b/json_to_tree.py index 5b73eb1..2251c8d 100644 --- a/json_to_tree.py +++ b/json_to_tree.py @@ -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]