1
我有一个ASP.NET MVC应用程序,该应用程序返回使用Json()方法转换为JSON的Customer对象。转换为JSON时,如何在Null属性中返回空字符串?
return Json(Repository.Customer.Get(id));
Customer对象的其中一个属性是Customer.Gender。如果性别属性包含Null值,在客户端上收到的JSON对象包含
Gender: "<null>"
有没有办法有Null值的属性包含在JSON对象,而不是“空”文本空字符串?
到这里看看: http://stackoverflow.com/questions/1031088/how-to-avoid-null-strings-when-binding-json-data-on-client-side –