How can I parse a file of this kind:
{"group":"1"}{"group":"2"}{"group":"3"}
Usually I parse in this way:
NSString *fileContent = [[NSString alloc] initWithContentsOfFile:reloadPath];
SBJsonParser *parser = [[SBJsonParser alloc] init];
NSDictionary *data = (NSDictionary *) [parser objectWithString:fileContent error:nil];
// getting the data from inside of "menu"
//NSString *message = (NSString *) [data objectForKey:@"message"];
//NSString *name = (NSString *) [data objectForKey:@"name"];
NSArray *messagearray = [data objectForKey:@"message"];
NSArray *namearray = [data objectForKey:@"name"];
NSDictionary* Dictionary = [NSDictionary dictionaryWithObjects:messagearray forKeys:namearray];
…objects of this king…
{"message":["Besth"],"name":["thgh"]}
…but in the type I want to parse, which is the key and object??
By the way I want to retrieve a list like this: 1, 2, 3, …
This is not valid JSON. You can validate for example at: http://jsonlint.com
You could rewrite it as valid JSON like so:
Then you could extract the data by doing something like this: