开发者

How can I check if the response is a valid JSON in cocoa

Is there a way to check if the response from开发者_开发百科 a web service call is valid JSON?

I am using ASIHTTP by the way for all communication.


Attempt to parse the response—if you are successful, it's valid JSON. For example, if you were using json-framework:

SBJsonParser *parser = [[[SBJsonParser alloc] init] autorelease];
id object = [parser objectWithString:[request responseString]];

if (object != nil) {
  // Success!
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜