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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:41:55+00:00 2026-05-26T21:41:55+00:00

The following is encoded JSON data from a PHP webpage. { { news_date =

  • 0

The following is encoded JSON data from a PHP webpage.

{
    {
        "news_date" = "2011-11-09";
        "news_id" = 5;
        "news_imageName" = "newsImage_111110_7633.jpg";
        "news_thread" = "test1";
        "news_title" = "test1 Title";
    },
    {
        "news_date" = "2011-11-10";
        "news_id" = 12;
        "news_imageName" = "newsImage_111110_2060.jpg";
        "news_thread" = "thread2";
        "news_title" = "title2";
    },
// and so on...
}

I’d like to grab one buch of info (date/id/image/thread/title), and store it as an instance of a class. However, I have no clue on how to access each object in 2D arrays.
The following is the code I’ve written to test if I can access them, but it doesn’t work.

What would be the problem?

NSURL *jsonURL = [NSURL URLWithString:@"http://www.sangminkim.com/UBCKISS/category/news/jsonNews.php"];
NSString *jsonData = [[NSString alloc] initWithContentsOfURL:jsonURL];
SBJsonParser *parser = [[SBJsonParser alloc] init];
contentArray = [parser objectWithString:jsonData];
NSLog(@"array: %@", [[contentArray objectAtIndex:0] objectAtIndex:0]); // CRASH!!
  • 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-05-26T21:41:56+00:00Added an answer on May 26, 2026 at 9:41 pm

    In JSON terminology, that’s not a two-dimensional array: it’s an array whose elements are objects. In Cocoa terminology, it’s an array whose elements are dictionaries.

    You can read them like this:

    NSArray *newsArray = [parser objectWithString:jsonData];
    
    for (NSDictionary *newsItem in newsArray) {
        NSString *newsDate = [newsItem objectForKey:@"news_date"];
        NSUInteger newsId = [[newsItem objectForKey:@"news_id"] integerValue];
        NSString *newsImageName = [newsItem objectForKey:@"news_imageName"];
        NSString *newsThread = [newsItem objectForKey:@"news_thread"];
        NSString *newsTitle = [newsItem objectForKey:@"news_title"];
    
        // Do something with the data above
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php script to retrieve data from a MysQL databse following an
I'm using AJAX to get data from server. The following is the php file.
I'm sending the following from PHP to JSON print json_encode(array('success' => TRUE, 'status' =>
I'm using following code but cannot return data from MySQL. This is the output:
I'm building a PHP script that feeds JSON data to another script. My script
I don't understand one thing. If I want to get JSON data (key-value-pairs) from
I have the following json data in a Javascript variable result : [ Object
I have a PHP script that selects some data from mysql and throw it
I have the following quite simple test PHP code that extracts the data and
I have been trying to add data from my ajax query that returns json

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.