I'm debugging in Visual Studio Code and I have a JSON object that I would like to copy as text to the clipboard.
Is this possible inside of Visual Studio Code?
Go to menu Debug->Windows->Locals to make it appear. Watch Although it is a little manually you also can use 'Watch' you can drag and drop any variable to this window or right click then add to watch. Go to menu Debug->Windows->Watch to make it appear. Note.
In Visual Studio debug mode it's possible to hover over variables to show their value and then right-click to "Copy", "Copy Expression" or "Copy Value". In case the variable is an object and not just a basic type, there's a + sign to expand and explore the object.
You can also click on the line you want to skip to and hit Ctrl+F10 (Run to Cursor).
I found two ways to do that, both of which are a bit hacky (in my eyes).
I think there will be a limit to the size of the string that this can output, but it was satisfactory for my requirements.
console.log(JSON.stringify(yourJsonObject))
This method only works up to a limited size of the resulting json string (it looks like 10'000 characters).
tmpJson
var tmpJson = JSON.stringify(yourJsonObject)
tmpJson
with the string representation of your json objectIf 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.
There is an open issue regarding this: https://github.com/microsoft/vscode-java-debug/issues/624
Workaround :
(tested on Java, not JavaScript)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With