我正在尝试返回一个对象的美化 json 序列化并使用 Response.Write 在 ASP.NET 中输出它,这是我的代码。不要介意不验证用户输入的明显罪行,这只是一个愚蠢的小测试应用程序。
try
{
var customer = this.sc.GetCustomer(Convert.ToInt32(TextBox1.Text));
var json = JsonConvert.SerializeObject(customer, Formatting.Indented);
Response.Write(json);
}
catch (Exception ex)
{
Response.Write("An error occurred: " + ex.Message);
}
Formatting.Indented 似乎没有效果。我究竟做错了什么?