Last active
January 3, 2016 05:09
-
-
Save vikingosegundo/8413542 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#import <Foundation/Foundation.h> | |
int main(int argc, const char * argv[]) | |
{ | |
@autoreleasepool { | |
NSString *jsonString = @"{\"corpUserWs\":{\"loginMsg\":\"User is locked out. Please request for your account to be unlocked.\",\"requestStatus\":0,\"sessionId\":\"16gxtse746yqj\"}}"; | |
NSString *jsonString2 = @"[{\"corpUserWs\":{\"loginMsg\":\"User is locked out. Please request for your account to be unlocked.\",\"requestStatus\":0,\"sessionId\":\"16gxtse746yqj\"}}]"; | |
for (NSString *string in @[jsonString, jsonString2]) { | |
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding]; | |
NSError *e; | |
id jsonObj = [NSJSONSerialization JSONObjectWithData: data options: NSJSONReadingMutableContainers error: &e]; | |
if (jsonObj) { | |
NSLog(@"%@", NSStringFromClass([jsonObj class])); | |
} | |
if ([jsonObj isKindOfClass:[NSDictionary class]]) { | |
NSLog(@"JSON is parsed to a dictionary"); | |
} else if([jsonObj isKindOfClass:[NSArray class]]){ | |
NSLog(@"JSON is parsed to an array"); | |
} | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment