开发者

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

开发者 https://www.devze.com 2023-02-20 12:58 出处:网络
Is there a way to check if the response from开发者_开发百科 a web service call is valid JSON?

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

精彩评论

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