I am trying to find nearby places using api. Here is the json data that is returned from
NSDictionary *results = [jsonString JSONValue]; NSLog(@"%@", results); ( { code = 200; errorDetail = "This endpoint will stop returning groups in the future. Please use a current version, see http://bit.ly/lZx3NU."; errorType = deprecated; }, { groups = ( { items = ( { categories = ( { icon = "https://foursquare.com/img/categories/parks_outdoors/default.png"; id = 4bf58dd8d48988d163941735; name = Park; parents = ( "Great Outdoors" ); pluralName = Parks; primary = 1; shortName = Park; } );
Then I try to get a list of groups in an array with
NSArray *groups = [ (NSDictionary *)results objectForKey:@"groups"];
This returns the following error
2011-11-05 11:42:12.907 XperienzApp[1972:207] No of results returned: 0 Results : (null) 2011-11-05 11:42:13.225 XperienzApp[1972:207] -JSONValue failed. Error trace is: ( "Error Domain=org.brautaset.JSON.ErrorDomain Code=3 \"Unrecognised leading character\" UserInfo=0x5849cd0 {NSLocalizedDescription=Unrecognised leading character}" ) 2011-11-05 11:42:13.225 XperienzApp[1972:207] No of results returned: 0 Results : (null)
How can I make it out?
Edit: I tried the suggested technique, this gives me an array
id groups = [[(NSDictionary *)results objectForKey:@"response"] objectForKey:@"groups"]; if ([results count] > 1){ NSLog(@"groups class %@\ngroups %@ %d", groups, [groups class], [groups count]);
The output of the log is:
{ categories = ( { icon = "https://foursquare.com/img/categories/nightlife/danceparty.png"; id = 4bf58dd8d48988d11f941735; name = Nightclub; parents = ( "Nightlife Spots" ); pluralName = Nightclubs; primary = 1; shortName = Nightclub; } ); contact = { }; hereNow = { count = 0; }; id = 4eb33ba561af0dda8f673c1b; location = { address = "144 Willow St 4R"; city = Brooklyn; crossStreet = Pierrepont; distance = 462; lat = "40.696864"; lng = "-73.996409"; postalCode = 11201; state = NY; }; name = "Entertainment 720, Ltd."; stats = { checkinsCount = 3; tipCount = 0; usersCount = 1; }; verified = 0; } ); name = Nearby; type = nearby; } ) groups __NSArrayM 1
This is not json again and it is hard to figure out how I can get the result in json.
source share