Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Convert String to NSData Json Object
//gcc 5.0.4 #import <Foundation/Foundation.h> @interface Util:NSObject - (NSData *)parseJson:(NSString *) jsonstring; @end int main (int argc, const char * argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString* data = @" [ { \"ID\":1,\"idSort\" : 0,\"deleted\":0,\"storyboardName\" : \"MLMember\",\"dispalyTitle\" : \"76.360779\",\"rightLevel\" : \"10.010490\",\"showTabBar\" : 1,\"openWeb\" : 0,\"webUrl\":\"\"},{\"ID\":10,\"idSort\" : 0,\"deleted\":0,\"storyboardName\" : \"0.00\",\"dispalyTitle\" : \"76.360779\",\"rightLevel\" : \"10.010490\",\"showTabBar\" : 1,\"openWeb\" : 0,\"webUrl\":\"\"}]"; Util *util = [[Util alloc]init]; NSData* obj = [util parseJson:data]; NSError *jsonError; id allKeys = [NSJSONSerialization JSONObjectWithData:obj options:NSJSONWritingPrettyPrinted error:&jsonError]; int i = 0; for (i=0; i<[allKeys count]; i++) { NSDictionary *arrayResult = [allKeys objectAtIndex:i]; NSLog(@"name=%@",[arrayResult objectForKey:@"storyboardName"]); NSLog(@"ID=%@",[arrayResult objectForKey:@"ID"]); } [pool drain]; return 0; } @implementation Util - (NSData *)parseJson:(NSString *) jsonstring { NSString* jsonString = jsonstring; NSData* jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding]; return jsonData; } @end
run
|
edit
|
history
|
help
0
geomatric operations in objective c
NSSet ex
primitive datatypes objective c
string compare
NSSet Program in objectice-c
string replace
Even and Odd numbers by Erick Benites
Book NSSet
fullname
arary