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!
}
精彩评论