如何Visual Studio立即Windows打印格式缩进JSON?
How Visual Studio Immediate Windows to print format indented JSON?
我在调试时尝试使用Newtonsoft.Json.JsonConvert.SerializeObject(rows, Formatting.Indented)
将变量转换为json,但是vs immediate只显示non-format像图像
这样的字符串
我希望得到如下 LINQPad 的结果
就我个人而言,我没有使用立即数 window,因为我发现它不如其他选项有用。
要检查值,您可以将鼠标悬停在变量上并单击放大镜图标,它将以 ToString()
表示形式显示存储的数据。您可以选择其他可视化工具,例如 json
、xml
或 html
,下拉菜单位于图标附近。缺点是你需要声明变量。
其他选项是使用 Watch
面板(在调试期间单击 debug -> windows -> watch -> watch 1
)。它允许您检查变量、覆盖它们并调用方法
如果您想打印换行符和制表符,您可以在 Window 中输入变量名,然后输入字符串“,nq”。
所以不要在即时 Window 中输入 Newtonsoft.Json.JsonConvert.SerializeObject(rows, Formatting.Indented)
,而是输入 Newtonsoft.Json.JsonConvert.SerializeObject(rows, Formatting.Indented),nq
.
末尾的“,nq”用作立即数Window 的“格式说明符”。详细了解 here.
感谢用户davesem for pointing this out here。
我在调试时尝试使用Newtonsoft.Json.JsonConvert.SerializeObject(rows, Formatting.Indented)
将变量转换为json,但是vs immediate只显示non-format像图像
我希望得到如下 LINQPad 的结果
就我个人而言,我没有使用立即数 window,因为我发现它不如其他选项有用。
要检查值,您可以将鼠标悬停在变量上并单击放大镜图标,它将以 ToString()
表示形式显示存储的数据。您可以选择其他可视化工具,例如 json
、xml
或 html
,下拉菜单位于图标附近。缺点是你需要声明变量。
其他选项是使用 Watch
面板(在调试期间单击 debug -> windows -> watch -> watch 1
)。它允许您检查变量、覆盖它们并调用方法
如果您想打印换行符和制表符,您可以在 Window 中输入变量名,然后输入字符串“,nq”。
所以不要在即时 Window 中输入 Newtonsoft.Json.JsonConvert.SerializeObject(rows, Formatting.Indented)
,而是输入 Newtonsoft.Json.JsonConvert.SerializeObject(rows, Formatting.Indented),nq
.
末尾的“,nq”用作立即数Window 的“格式说明符”。详细了解 here.
感谢用户davesem for pointing this out here。