Refactor debug JSON

This commit is contained in:
vvzvlad
2025-03-24 16:54:45 +03:00
parent 54b3175bdf
commit d9443b8a54
+2 -6
View File
@@ -303,12 +303,8 @@ class PostParser:
# Add raw JSON debug output if debug is enabled
if debug:
debug_message = copy.deepcopy(message)
debug_json = json.dumps(debug_message, default=str, ensure_ascii=False)
# Format JSON by replacing braces with newlines
formatted_json = debug_json.replace('{', '{\n').replace('}', '\n}').replace(',', ',\n')
html_content.append(f'<pre class="debug-json" style="background: #f5f5f5; padding: 10px; margin-top: 20px; overflow-x: auto; font-size: 10px; white-space: pre-wrap;">{formatted_json}</pre>')
debug_json = json.dumps(message, indent=2, ensure_ascii=False, default=str)
html_content.append(f'<pre class="debug-json" style="background: #f5f5f5; padding: 10px; margin-top: 20px; overflow-x: auto; font-size: 10px; white-space: pre-wrap;">{html.escape(debug_json)}</pre>')
html_content = '\n'.join(html_content)
return html_content