Newtonsoft.Json设置类的属性不序列化

时间:2021-06-06 22:23:39

参考页面:

http://www.yuanjiaocheng.net/webapi/parameter-binding.html

http://www.yuanjiaocheng.net/webapi/action-method-returntype.html

http://www.yuanjiaocheng.net/webapi/web-api-reqresq-format.html

http://www.yuanjiaocheng.net/webapi/media-formatter.html

http://www.yuanjiaocheng.net/webapi/webapi-filters.html

 1,现象:网站应用程序池停止运行,系统日志为:
  1)

错误应用程序名称: w3wp.exe,版本: 7.5.7601.17514,时间戳: 0x4ce7a5f8
错误模块名称: unknown,版本: 0.0.0.0,时间戳: 0x00000000
异常代码: 0xc00000fd
错误偏移量: 0x36773800
错误进程 ID: 0x1b0c
错误应用程序启动时间: 0x01d2626116b1ea92
错误应用程序路径: C:\Windows\SysWOW64\inetsrv\w3wp.exe
错误模块路径: unknown
报告 ID: 54a68ba9-ce54-11e6-aeff-1866dae93909

2)

问题签名:
P1: w3wp.exe
P2: 7.5.7601.17514
P3: 4ce7a5f8
P4: *****
P5: 1.0.0.0
P6: 5865f074
P7: 72a
P8: 0
P9: System.*Exception
P10:

 
2,JsonConvert.SerializeObject(o, Formatting.Indented);这的时候报错 
  o是一个对象。
  最终报错位置为

public Decimal budget
{
set { _budget = value; }
get { return _budget; }
}

 未处理System.*Exception Message: “System.*Exception”类型的未经处理的异常在 *** 中发生
 
3,错误分析:Newtonsoft方法直接报错,无法调试,难道是Newtonsoft无法序列化Decimal类型的属性?
 
4,迂回解决方法:设置budget不可被序列化。
 
5,跪求真正的可以序列化Decimal类型的属性的方法