2
"[
  {
    \"TheatreName\": \"FunCinemas\",
    \"TheatreId\": 1,
    \"City\": \"Chandigarh\"
  },
  {
    \"TheatreName\": \"PVRElanteMall\",
    \"TheatreId\": 2,
    \"City\": \"Chandigarh\"
  },
  {
    \"TheatreName\": \"PiccadilySquare\",
    \"TheatreId\": 3,
    \"City\": \"Chandigarh\"
  }
]"

I want to parse these data, that is separate all the objects Theatrename, id, city

Janmenjaya
  • 4,149
  • 1
  • 23
  • 43
Praveen Jain
  • 73
  • 1
  • 5

1 Answers1

6

I tried to create a demo scenario with your JSON value

Here is the code :

- (void)viewDidLoad {
    [super viewDidLoad];

    NSString *str = @"[{\"TheatreName\": \"FunCinemas\",\"TheatreId\": 1,\"City\":\"Chandigarh\"},{\"TheatreName\":\"PVRElanteMall\",\"TheatreId\": 2,\"City\": \"Chandigarh\"},{\"TheatreName\": \"PiccadilySquare\",\"TheatreId\": 3,\"City\": \"Chandigarh\"}]";
    NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding];

    NSError *err = nil;
    NSArray *jsonData = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&err];

    NSMutableArray *arrResult = [NSMutableArray array];

    for (NSDictionary *dict in jsonData) {

        NSLog(@"TheatreName %@", dict[@"TheatreName"]);
        NSLog(@"TheatreId %@", dict[@"TheatreId"]);
        NSLog(@"City %@", dict[@"City"]);

        [arrResult addObject:dict];
    }

}
Janmenjaya
  • 4,149
  • 1
  • 23
  • 43