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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:40:31+00:00 2026-05-20T15:40:31+00:00

I’m just playing with the JSON parser in iOS it’s working fine as a

  • 0

I’m just playing with the JSON parser in iOS it’s working fine as a ( simple ) example . But I was wonder how one would actually parse something (a bit) more complicated, the a Twitter trends JSON, like this :

{
    "trends": {
        "2011-03-13 11:42:17": [
            {
                "events": null,
                "query": "Fukushima",
                "promoted_content": null,
                "name": "Fukushima"
            },
            {
                "events": null,
                "query": "Rebecca Black",
                "promoted_content": null,
                "name": "Rebecca Black"
            },
            {
                "events": null,
                "query": "Pearl Harbour",
                "promoted_content": null,
                "name": "Pearl Harbour"
            },
            ...
            {
                "events": null,
                "query": "Magdalena Neuner",
                "promoted_content": null,
                "name": "Magdalena Neuner"
            }
        ]
    },
    "as_of": 1300016537
}

How would one just return the first 3 queries ? in this instance : Fukushima, Rebecca Black and Pearl Harbour .

Using the example code, it goes something like this :

for (int i = 0; i < [luckyNumbers count]; i++)
    [text appendFormat:@"%@\n", [luckyNumbers objectAtIndex:i]];

This is for a much simpler feed though, can it be approached the same way for what I’m looking for ?


EDIT

I am now trying to return the value of “query”:

So I`m doing this :

NSLog(@"%@", [[luckyNumbers objectForKey:@"trends"]);

This of course logs the content of the key “trend”, how do I go about returning not only the first ( and only ) key of trends but also dig one more level down to return the content of “query” ??

I’ve also tried something like this :

NSString *date = [[[luckyNumbers valueForKeyPath:@"trends"] allKeys] description];
NSArray *trends = [luckyNumbers objectForKey:@"trends"];
NSLog(@"%@", [trends valueForKeyPath:date]);

but no go …

  • 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-20T15:40:32+00:00Added an answer on May 20, 2026 at 3:40 pm

    JSON maps like for like to dictionaries and arrays – that’s the point of it (versus XML). How you would get information out of a particular JSON file would depend on how that file was designed in the first place.

    Square brackets in JSON indicate arrays – curly braces indicate dictionaries (objects). So in your example we see that there’s a dictionary containing an object with the key ‘trends’, an object that itself is a dictionary.

    It’s going to be easier for you to get a handle on this if you log the output of your parsed array, because you’ll see the entire structure of NSArrays and NSDictionaries. To do this, once you’ve parsed your JSON you’d want to do something like:

    NSLog([parsedJsonResult description]);

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

Sidebar

Related Questions

No related questions found

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.