vscode-debug-visualizer
vscode-debug-visualizer copied to clipboard
First time using this - Python
This is my first time using this extension. I'm trying to display the array
y as a table, but it looks like a complete mess... Can someone guide me on how to use this?
Note: the data must be transferred to the Visualizer as a json string for languages that only support BasicSupport. For the structure of json strings, see Visualization Playground Otherwise the Visualizer cannot display the data correctly.
The attached example uses the visualizeArray() function to create the json string. In the debugger, the call visualizeArray(y) must be specified instead of the variable y.
# Demo for visualization of an array by using VS Code Debug Visualizer.
# ⚠️ Attention: the transfer to the Visualizer must be made as a json string
# for languages that only support BasicSupport.
import json
def visualizeArray(arr):
"""Serialize an array into a format the visualizer can understand."""
formatted = {
"kind": {"grid": True},
"rows": [
{
"columns": [
{"content": str(value), "tag": str(value)} for value in arr
],
}
],
}
return json.dumps(formatted)
y = [10,20,30]
y = [10,20,30,40]
y = [10,99,30,-3]
y = [0,99,30,-3, 4, 62]