Reputation: 3811
I tried to use Newtonsoft.Json.JsonConvert.SerializeObject(rows, Formatting.Indented)
to convert variable to json when debugging, but vs immediate only show non-format string like image
I expect to get result like below LINQPad's result
Upvotes: 0
Views: 2854
Reputation: 1062
Another approach could be saving json to file, it will greatly help to analyze and compare different outputs
System.IO.File.WriteAllText(@"c:\temp\debug_file.json", Newtonsoft.Json.JsonConvert.SerializeObject(tSet, Newtonsoft.Json.Formatting.Indented));
Upvotes: 0
Reputation: 326
If you would like to print newline and tab characters, you can type the variable name into the Immediate Window followed by the string ",nq".
So instead of typing Newtonsoft.Json.JsonConvert.SerializeObject(rows, Formatting.Indented)
into the Immediate Window, you would type Newtonsoft.Json.JsonConvert.SerializeObject(rows, Formatting.Indented),nq
.
The ",nq" at the end serves as a "format specifier" for the Immediate Window. Find out more about that here.
Thanks to user davesem for pointing this out here.
Upvotes: 2
Reputation: 4518
Personally I'm not using immediate window because find it less useful than other options.
To inspect value you can hover over variable and click on magnifier icon, it will display stored data with ToString()
representation. Optionally you can choose other visualizer like json
, xml
or html
with dropdown near icon. Downside is that you need declared variable.
Other option is to use Watch
panel (during debug click debug -> windows -> watch -> watch 1
). It allows you to inspect variables, override them and call methods
Upvotes: 1