“JSONValue failed”从服务器获取数据到iPhone时出错 [英] "JSONValue failed" Error while fetching data from server into iPhone

查看:198
本文介绍了“JSONValue failed”从服务器获取数据到iPhone时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从服务器获取数据到我的iPhone应用程序。

I am fetching data from server into my iPhone app.

为了从服务器获取数据,我使用HTTP Post方法和解析获取的数据我使用SBJSON Parser。

For fetching data from server, I am using HTTP Post method and for parsing data obtained I am using SBJSON Parser.

当我第一次启动应用程式时,无法撷取资料。

When the first time my app launches, the data is not fetched.

故障登录控制台。该应用程序不会崩溃,但只是该数据无法抓取。

It shows the following failure log in Console. The app does not crash but just that data is not fetched.

<html>Your request timed out.  
Please retry the request.                                                                                                 </html>
2011-04-21 08:39:06.339 Hive[1594:207] -JSONValue failed. Error trace is: (
    "Error Domain=org.brautaset.JSON.ErrorDomain Code=3 \"Unrecognised leading character\"   UserInfo=0x4cabe90 {NSLocalizedDescription=Unrecognised leading character}"
)

应用程序从第二次开始正确提取数据。

The app fetches data properly from the second time onwards. It only gives this error when the app runs the first time.

可能出错?

推荐答案

没有对服务器及其资源的分析,很难确定服务器为什么花费太长时间来响应。

Without analysis of the server and its resources it is difficult to determine why the server is taking too long to respond.

大约是在上次尝试JSON和下次第一次尝试之间发生多少时间。也许可以看看你是否使用网络浏览器重新创建它。

One thing to think about is how much time occurs between the last time you make the JSON attempt and the next time you make your "first attempt". Maybe then see if you an recreate it using a web browser.

服务器是否是生产质量服务器?如果没有,它可能是旋转来回答第一个请求花费太长的第一个响应。

Is the server a production quality server? If not, it may be "spinning up" to answer the first request which takes too long for the first response.

我个人地写了一个通用的JSON feed类,失败重试选项。如果它没有收到任何内容或无效的JSON,它将根据你传递的内容以y秒为间隔重试x次。最初需要更多的工作,但它会得到回报的两个原因。

Personally, I wrote a generic JSON feed class that has a failure retry option. If it receives nothing or invalid JSON, it will retry x times at y seconds intervals based on what you pass it. It takes a little more work initially but it will payoff for two reasons.

1)它可以重复使用一遍又一次更新,像使用ASIHTTRequest像Terente的好建议可以在单个文件中创建。

1) It can be reused over and over and an update, like using ASIHTTRequest like Terente's good suggestion can be made in a single file.

2)虽然您可能不希望响应失败,但服务器运行缓慢或网络问题可能会导致错误响应。

2) While you may not expect a response to fail, server slowness or network issues can occur causing a flawed response.

这篇关于“JSONValue failed”从服务器获取数据到iPhone时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆