我在iOS上使用的是RestKit v0.20.0-pre6。我的输入是来自运行在Google App Engine上的服务的JSON。这是从服务返回的内容:
{
action:"NOP",
payload:null,
timeStamp:new Date(1359427714679),
type:null
}这是我在输出窗口中从RestKit得到的错误信息:
E restkit.network:RKResponseMapperOperation.m:240
Failed to parse response data: Loaded an unprocessable response (200) with content type 'application/json'当调用NSJSONSerialization解析数据时,它会阻塞。我确信它就是包含new Date(1359427714679)的那一行,但是我不确定如何解析这行。RestKit文档提到要编写您自己的格式化程序,但我不清楚如何做到这一点。
任何关于如何解决这个问题的见解都将不胜感激。
发布于 2013-01-31 19:09:22
在这里,您的JSON有几个问题。首先,您的键需要使用反逗号"“。其次,您的web服务需要以字符串形式提供时间戳。
试试ISO8601格式,例如
{
"action" :"NOP",
"payload" : null,
"timeStamp" : "1901-12-13T20:45:52+00:00",
"type": null
}您可以通过将其粘贴到在线验证器(如http://www.jslint.com/ )中来检查您的JSON是否有效。
https://stackoverflow.com/questions/14574943
复制相似问题