开发者

iphone webservice

i want to invoke a url from开发者_StackOverflow iphone.I am using NSURLConnection the server sende response data,but the problem is response data contains only the html source of the corresponding page.I need the reposne as a JSON format.How to fix it


You need to FIX it on the server side (the WebApplication your iPhone connects to). You can't fix that by modifying the iPhone application.


The issue you have is a server side issue. The web service you are invoking needs to be set up to respond with a JSON format. To be properly compliant, the server needs to use the content encoding application/json and respond the properly formatted results.

If you are in control of your web service, you need to either detect that the request is coming from an iPhone, or provide a JSON specific URL. I would probably go for the latter as it makes your server a little easier to understand.

If you are not in control of your web service, you will have to talk to the people who are. That way they can take care of what you need, or point you to the right URL.


It depends on what you are trying to do. Most times, people use JSON to transfer data from a server side so a client side. In order to do that, the server side needs to have an API, that is in most times very easy to build, assuming that you have the data set (if you're using php, check json_encode). In other times, you are might looking to look for something in a web site which you don't own and don't work with. In that case, you need to build a specific parser which extracts the relevant information you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜