IPhone : How to convert data string to json object and string in ios?

on Tuesday, March 31, 2015

how to convert string to json object or json array in ios? my json string Like That.



{"Data": [{"ID":"1","Name":"Raj"},{"ID":"2","Name":"Rajneesh"}]}


i want to get ID or Name from this string please help me if anyone now this.


Thank You.


I try below code but print null



NSString *JsonString=@"{"Data": [{"ID":"1","Name":"Raj"},{"ID":"2","Name":"Rajneesh"}]}";
NSData *objectData = [JsonString dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:objectData options:0 error:&error];
NSArray* array = [json objectForKey:@"Data"];
NSLog(@"Print Array %@",array);

0 comments:

Post a Comment