繁体   English   中英

制作网络服务后如何在IOS应用程序中获得有效的json回复

[英]how to get valid json reply in IOS application after making a webservice

制作网络服务后,我的 JSON 响应如下

$response['success']=1;
$response['message']='enter successfully';
die(json_encode($response));

但是当我在 iOS 应用程序中运行它时,这给了我如下错误

JSON 文本未以数组或对象开头,并且没有设置允许片段的选项

您的 json 响应无效。请检查您的 json 对象。

试试下面的代码:

header('Content-Type: application/json');
$response['success']=1;
$response['message']='enter successfully';
print json_encode($response);
exit();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM