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

  • SEARCH
  • Home
  • 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 8754805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:42:43+00:00 2026-06-13T13:42:43+00:00

I have a simple JSON array that is returned from a zip code passed

  • 0

I have a simple JSON array that is returned from a zip code passed to a third party service.

http://api.geonames.org/findNearbyPostalCodes?postalcode=94115&country=US&radius=5&username=frequentz

I get an unknown error when trying to deserialize the results and I’m not sure what is going wrong.

Here is my connectionDidFinishLoading method, which fires as anticiapated but always fails…and I get the error in the last else if. Ideas?

-(void) connectionDidFinishLoading:(NSURLConnection *)connection {

NSLog(@"connectionDidFinishLoading...");

self.zipCodes = [NSMutableArray array];

NSError *error = nil;

id jsonObject = [NSJSONSerialization JSONObjectWithData:receivedData options:NSJSONReadingAllowFragments error:&error];

if (jsonObject != nil && error == nil) {

    NSLog(@"Successfully deserialized...");

    if ([jsonObject isKindOfClass:[NSDictionary class]]) {

        NSDictionary *deserializedDictionary = (NSDictionary *)jsonObject;
        NSLog(@"Deserialized JSON Dictionary = %@", deserializedDictionary);

        for (NSDictionary *item in jsonObject) {

          NSString *city = [item objectForKey:@"adminName2"];
          NSString *stateAbbreviation = [item objectForKey:@"adminCode1"];
          NSString *postalCode = [item objectForKey:@"postalCode"];
          NSString *distance = [item objectForKey:@"distance"];
          NSString *country = [item objectForKey:@"country"];
          NSString *stateName = [item objectForKey:@"stateName"];

          ZipCodes *zipCode = [[ZipCodes alloc] initWithName:city stateAbbrev:stateAbbreviation postalCode:postalCode distanceFromGPSZip:distance country:country stateFullName:stateName];

          [self.zipCodes addObject:zipCode];
        }
    }
    else if ([jsonObject isKindOfClass:[NSArray class]]){
        NSArray *deserializedArray = (NSArray *)jsonObject;
        NSLog(@"Deserialized JSON Array = %@", deserializedArray);
    }
    else {
        /* Some other object was returned. We don't know how to deal
         with this situation as the deserializer returns only dictionaries or arrays */
    }
}
else if (error != nil){
    NSLog(@"An error happened while deserializing the JSON data.");
}
}
  • 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-13T13:42:45+00:00Added an answer on June 13, 2026 at 1:42 pm

    I think you’re using the wrong service –it should be …findNearbyPostalCodesJSON…. To use the JSON service as far as I can tell from their website. This is their example URL:

    http://api.geonames.org/findNearbyPostalCodesJSON?postalcode=8775&country=CH&radius=10&username=demo

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSON response from a web service that I need to be
I have a long JSON string representing a string[] array being returned from a
I have a simple json string which contains a collection of objects http://sandapps.com/InAppAds/ads.json.txt When
I have a simple viewModel that I am creating from a MVC for to
I have a little app that pulls data from several API's. In all of
I have a simple array that I am trying to handle. It consists of
am just starting off with restkit for ios. I have a very simple json
I used to have this kind of simple JSON data and I could successfully
I have a 'simple' scenario: Read some JSON file, Filter or change some of
I have a simple scenario where i want to output only json to the

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.