Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8712027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:01:24+00:00 2026-06-13T05:01:24+00:00

I am retrieving json data from a url. The json string has one object

  • 0

I am retrieving json data from a url. The json “string” has one object that contains multiple objects inside of it, each of of the objects containing their own key, value properties…essentially the json object is an NSArray containing objects that are more or less dictionary objects. I’m trying to use NSJSONSerialization but there isn’t a lot of documentation on it, and I can’t seem to figure out how to Here is an example of what the json might look like:

{"allObjects":[{"firstName":"homer","middleName":"j","lastName":"simpson"
,"address": "123 evergreen terrace","countryCode":"US","zip":12345},
{"firstName": "marge","middleName":"b","lastName":"simpson","address":
"123 evergreen terrace","countryCode":"US","zip":12345}]}

(If it matters, the JSON object contains MANY more entries)

Are there specific “options” I need to use with NSJSONSerialization to get an array of dictionaries out (the array being “allObjects”)?

Any help would be greatly appreciated!

Thanks in advance.

UPDATE

This code results in an error:

@vishy I thought this too, but when I run this code,

NSArray *json = [NSJSONSerialization JSONObjectWithData:geoNamesJSON options: kNilOptions error:&error];
NSDictionary *dict = [json objectAtIndex:0];
NSArray *allKeys = [dict allKeys];
NSString *key = [[NSString alloc] init];
NSEnumerator *keyEnum = [allKeys objectEnumerator];
NSLog(@"All keys in the first dictionary object:");
while(key = [keyEnum nextObject]){
    NSLog(@"%@", key);}

I get this error:

-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x1fd7cd10
* Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[__NSCFDictionary
objectAtIndex:]: unrecognized selector sent to instance 0x1fd7cd10’
*
First throw call stack: (0x3796c2a3 0x35c7c97f 0x3796fe07 0x3796e531 0x378c5f68 0xf310b 0xf219d 0x38ca4321 0x38cdecfd 0x38d53cc1
0x38cd86a7 0x38cd8481 0x38c52abb 0x38cc78d7 0x355b9bd9 0x3665c4b7
0x366611bd 0x3793ff3b 0x378b2ebd 0x378b2d49 0x37def2eb 0x38c91301
0xd3551 0x3c39db20) libc++abi.dylib: terminate called throwing an
exception (lldb)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:01:25+00:00Added an answer on June 13, 2026 at 5:01 am

    Are you getting any values in array after doing this step

    NSArray *json = [NSJSONSerialization JSONObjectWithData:geoNamesJSON options:kNilOptions error:&error]; 
    

    i dont think so, as your json is a dictionary. It should be

    NSDictionary* json = [NSJSONSerialization JSONObjectWithData:geoNamesJSON options:kNilOptions error:&error];
    

    For info on handling json you can follow this tutorial.

    Edit: Parse the data in this way after getting the json dictionary using above lines

    NSArray* geoList = [geoDict objectForKey:@"geonames"];
    NSLog(@"first object in geolist--%@",[geoList objectAtIndex:0]);
    //each object in the array is a dictionary
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am retrieving a list of objects from json url and displaying it like
I have a query on retrieving data sent as JSON from a JavaScript, inside
I'm creating multiple form retrieving data from jquery. after that i want to work
I'm retrieving data from teamcity webservice in json. One of the data is a
I am retrieving data via JSON and PHP from a URL. I am having
I am having a little trouble retrieving the values from a JSON object that
I have a class which makes a url request and stores data from that
I'm having trouble retrieving JSONP data from one of my sites. On Site A
Hi im retrieving some data from a database using JSON and ajax. When i
I am successfully retrieving JSON data from a web service with GET using Restkit's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.