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

0

1 Answer 1

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];
    }

}
Sign up to request clarification or add additional context in comments.

2 Comments

Thanku ...it worked
Then accept and up vote the answer, so that other facing same issue can know.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.