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 8751073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:58:40+00:00 2026-06-13T12:58:40+00:00

I try to grab some data with json on ios 5. but i fail…

  • 0

I try to grab some data with json on ios 5. but i fail…
could someone help me and tell me why it didn’t work out.
here’s my implementation code

define :

#define kBgQueue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) //1
#define kLatestKivaLoansURL [NSURL URLWithString:@"http://jaksport.com/jarray.php"] //2

then in the viewdidload :

NSData* data = [NSData dataWithContentsOfURL:
                        kLatestKivaLoansURL];
        [self performSelectorOnMainThread:@selector(fetchedData:)
                               withObject:data waitUntilDone:YES];

this is the function:

- (void)fetchedData:(NSData *)responseData {
    //parse out the json data
    NSError* error;
    NSDictionary* json = [NSJSONSerialization
                          JSONObjectWithData:responseData //1
                                     options:kNilOptions
                                       error:&error];

    NSArray* key = [json objectForKey:@"price"]; //2

    NSLog(@"value: %@", key); //3


  }

this is the json file:

{
    "prices":
        {
        "price":[
            {
                "id":1,
                "name":"Rosie Gradas",
                "beer":4.5,
                "cider":4.5,
                "guinness":4
            },
            {
                "id":2,
                "name":"Wicked Wolf",
                "beer":5,
                "cider":4.5,
                "guinness":4
            },
            {
                "id":3,
                "name":"Cafe Posh",
                "beer":6,
                "cider":5.5,
                "guinness":5.5
            },
            {
                "id":4,
                "name":"My House",
                "beer":16,
                "cider":15.5,
                "guinness":15.5
            }
        ]
    }
}

the nslog always print out null value

  • 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-13T12:58:41+00:00Added an answer on June 13, 2026 at 12:58 pm

    The error is in how you acces the objects in your JSON :

    {
      "prices":
        {
        "price":[
            {
                "id":1,
                "name":"Rosie Gradas",
                "beer":4.5,
                "cider":4.5,
                "guinness":4
            }
    }
    

    Given a JSON like that to access the price array you use a syntax like this

    NSArray *price = [[json objectForKey:@"prices"]objecForkey:@"price"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just posting here to try and grab some help! I have been playing with
I am trying to grab just a single value from some json and am
I'm using Apache Commons HttpClient to grab some data from a server. My problem
I want to grab some data from remote database and I have some networking
I'm trying to grab some data using Selenium and xpaths. The following xpath works
I am programming a script that will grab some data from my website using
I think this is a general Java question, but it does involve some Android
Greetings, I am currently exploring some extreme programming and try to stick as much
I have a form built with some custom validators and they work like a
I'm using lapply to try to split up a character string in a data

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.