【发布时间】:2013-03-17 00:37:29
【问题描述】:
我正在使用AFJSONRequestOperation 请求服务器并解析返回的 JSON 响应,但是在解析时,我收到了这个错误:
NSDebugDescription = "JSON text did not start with array or object and option to allow fragments not set.";
我检查了 API,它正在返回 JSON 数据:
header('Content-type: text/json');
$arr[] = array("Message" => "update succeeded");
echo '{"Result":'.json_encode($arr).'}';
知道如何解决这个问题吗?
编辑
我尝试从浏览器调用 API 并将请求包含在 url 中,因此我得到了有效的 JSON 响应:
{"Result":[{"Message":"update succeeded"}]}
【问题讨论】:
-
能否把
AFJSONRequestoperation收到的JSON字符串贴出来。 -
嗨,我在失败块中得到的 JSON 是
(null) -
你能在浏览器中运行 api 并包含对问题的响应吗?
-
是的,我已经这样做了,请看看我的编辑:)
-
我不懂 PHP,但你回显的整个内容不应该被包裹在 JSON_encode 中吗?
标签: php ios afnetworking