Can JavaScriptSerializer exclude properties with null/default values?

前端 未结 7 1137
野趣味
野趣味 2020-12-01 05:08

I\'m using JavaScriptSerializer to serialize some entity objects.

The problem is, many of the public properties contain null or default values. Is there any way to m

7条回答
  •  Happy的楠姐
    2020-12-01 06:06

    Without changing toe DataContractSerializer

    You can use ScriptIgnoreAttribute

    [1] http://msdn.microsoft.com/en-us/library/system.web.script.serialization.scriptignoreattribute.aspx

提交回复
热议问题