asp.net – 为什么这个JSON返回“无效的JSON原语”?
发布时间:2020-05-28 11:46:33 所属栏目:asp.Net 来源:互联网
导读:以下 JSON未反序列化.这显然是因为DECIMALS在保存JSON中.我该如何解决? 这个初始JSON来自服务器和IS VALID: { AppropriationAmount: 25000000, AppropriationHours: 56300, ArrThreshold: 11, ClientKey: 24, Descri
|
以下 JSON未反序列化.这显然是因为DECIMALS在保存JSON中.我该如何解决? 这个初始JSON来自服务器和IS VALID: {
"AppropriationAmount": 25000000,"AppropriationHours": 56300,"ArrThreshold": 11,"ClientKey": 24,"Description": 'Find and incarcerate the escaped prisoner',"DirectHours": 50000,"EndDate": '3/31/2011',"EngineeringHours": 4000,"IndirectHours": 2000,"Key": 1589,"Number": '0',"OtherHours": 300,"ProductivityCurveType": 'BurnedEarned',"ProjectManager": 'Doctor Who',"ProjectName": 'Prisoner ZERO',"StartDate": '5/1/2010'
}
这个后续的JSON发送到服务器FAILS: {
"AppropriationAmount": 56300.00,"AppropriationHours": 25000000.00,"ArrThreshold": 11.00,"ClientKey":,"DirectHours": 50000.00,"EngineeringHours": 4000.00,"IndirectHours": 2000.00,"OtherHours": 300.00,"StartDate": '5/1/2010'
}
此代码抛出错误: try
{
if (!String.IsNullOrEmpty(this.JSON))
{
serializer = new JavaScriptSerializer();
dialog = serializer.Deserialize<ProjectDecorator>(this.JSON);
}
}
catch (Exception ex)
{
// The message shows here
}
抛出的错误看起来像: {"Invalid JSON primitive: ."}
解决方法ClientKey不仅没有价值,而且还因为没有将键和值放在双引号(“”)中而冒着JSON有效性的风险.您的密钥没问题,但字符串值必须用双引号括起来.看看JSON网站,看看哪些是允许的,哪些不是. (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 下载ASP.NET MVC C#中字节数组列表中包含的多个文件
- asp.net-mvc – 使用@ Html.DisplayNameFor()与PagedList
- asp.net-mvc-4 – DataAnnotation Range属性的客户端验证之
- asp.net-mvc – 使用IIS 7重写模块重写Ampersand URL
- asp.net-mvc – 在ASP.NET MVC3中有一个无会话控制器的情况
- asp.net-mvc – 从客户端检测到潜在危险的Request.Form值
- asp.net菜单skiplink
- asp.net-mvc – 如何将用户重定向到ASP.NET MVC中的自定义4
- asp.net – 命名Dom元素的Id属性的最佳实践
- asp.net – 应用程序池循环如何影响ASP Net会话状态?
推荐文章
站长推荐
- asp.net – 如何添加.aspx页面到现有的MVC 4项目
- asp.net – 通过web.config覆盖machine.config
- 经典ASP和ASP.NET集成
- asp.net-mvc-3 – 造型ASP.NET MVC验证错误?
- asp.net-mvc – 以Razor语法为Telerik MVC Grid定
- asp.net – 自定义Web字体在IE9中不起作用
- asp.net-mvc – 在自定义编辑器中只包含一次脚本
- 认证 – WebApi ActionFilterAttribute,HttpActi
- asp.net-mvc – ASP.NET MVC App中基于声明的条件
- asp.net – MVC3 Controller文件夹不会出现在URL
热点阅读
