通过跳过NULL属性来减小JSON对象的大小

时间:2014-08-19 21:27:12

标签: ajax asp.net-mvc json

AJAX调用返回的JSON对象可能有多个具有NULL值的属性:

{
 Id: 1,
 Prop1: null,
 Prop2: null,
 Prop3: "abc"
}

有没有办法告诉MVC跳过返回对象中的空值? JSON对象的这种精简版本会减少很多有效负载。

{
 Id: 1,
 Prop3: "abc"
}

有没有人对这种方法有任何想法?

0 个答案:

没有答案