I found two ways to do that, both of which are a bit hacky (in my eyes).
Use console.log
I think there will be a limit to the size of the string that this can output, but it was satisfactory for my requirements.
- In the debug console, write
console.log(JSON.stringify(yourJsonObject)) - Copy the resulting output from the debug console. That can be a bit tedious for long strings, but a combination of mouse and keyboard (ctrl-shift-end) worked ok for me.
Use a watch (limited to 10’000 characters)
This method only works up to a limited size of the resulting json string (it looks like 10’000 characters).
- Set a breakpoint in a reasonable location where your variable is in scope and start your app.
- Go to the debug view, add a watch for a temporary variable, e.g.
tmpJson - Get your breakpoint to hit.
- In the debug console, write
var tmpJson = JSON.stringify(yourJsonObject) - This will now have populated the watched variable
tmpJsonwith the string representation of your json object - In the debug view, right click on the watched variable, click copy.
If the string is too long, it cuts it off with a message like the following:
...,"typeName":"rouParallel","toolAssembly":{"id":"ASKA800201","description":"CeonoglodaloD50R6z5","c... (length: 80365)"
But it would work for smaller objects. Maybe this helps some people.
It would be great to have this properly built-in with vscode.