Created
May 21, 2013 08:44
-
-
Save phnessu4/5618391 to your computer and use it in GitHub Desktop.
json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSError *error = nil; | |
NSData *jsonData = [json dataUsingEncoding:NSUTF8StringEncoding]; | |
if (jsonData) { | |
id jsonObjects = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error]; | |
if (error != nil) { | |
NSAssert(true, @"error is %@", [error localizedDescription]); | |
} | |
if ([jsonObjects isKindOfClass:[NSDictionary class]]) { | |
status = [[jsonObjects valueForKey:@"apistatus"] intValue]; | |
result = [jsonObjects valueForKey:@"result"]; | |
if ([result valueForKey:@"error"] != nil) { | |
errorCode = [[result valueForKey:@"error_code"] intValue]; | |
errorInfo = [result valueForKey:@"error"]; | |
} | |
}else{ | |
NSAssert(true, @"not support type to decode json, %@ : %@",jsonObjects, [jsonObjects class]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment