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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:43:45+00:00 2026-06-03T03:43:45+00:00

Hi i have some problem parsing the json in IOS. This is the json

  • 0

Hi i have some problem parsing the json in IOS. This is the json data.

{
"app_info": [
    {
        "app_name": "haka",
        "sync_protocol_version": "1"
    }
],
"updates": [
    {
        "timestamp": "Sat Apr 21 13:04:08 IST 2012",
        "people": [
            {
                "personal_info": [
                    {
                        "first_name": "phlox",
                        "last_name": "",
                        "employee_id": "010",
                        "gender": "-",
                        "marital_status": "-",
                        "nationality": "Denobulan",
                        "dob": "re-23",
                        "photo": "http://c.cc/users/010/profile/image"
                    }
                ],
                "contact_details": [
                    {
                        "address": [
                            {
                                "street": "#1, this way",
                                "city": "tank",
                                "state": "sick bay",
                                "zip": "0978",
                                "country": "Enterprise"
                            }
                        ],
                        "telephone": [
                            {
                                "work": "010",
                                "mobile": "010",
                                "home": "010"
                            }
                        ],
                        "email": [
                            {
                                "work": "phlox@nx-10.ent",
                                "personal": ""
                            }
                        ]
                    }
                ],
                "emergency": [
                    {
                        "contact": [
                            {
                                "name": "-",
                                "relationship": "",
                                "telephone": [
                                    {
                                        "work": "",
                                        "home": "",
                                        "mobile": ""
                                    }
                                ]
                            }
                        ],
                        "blood_group": ""
                    }
                ],
                "categorization": [
                    {
                        "designation": "",
                        "department": "",
                        "location": "",
                        "joining_date": ""
                    }
                ]
            },
            {
                "personal_info": [
                    {
                        "first_name": "",
                        "last_name": "",
                        "employee_id": "",
                        "gender": "",
                        "marital_status": "",
                        "nationality": "",
                        "dob": "",
                        "photo": ""
                    }
                ],
                "contact_details": [
                    {
                        "address": [
                            {
                                "street": "",
                                "city": "",
                                "state": "",
                                "zip": "",
                                "country": ""
                            }
                        ],
                        "telephone": [
                            {
                                "work": "",
                                "mobile": "",
                                "home": ""
                            }
                        ],
                        "email": [
                            {
                                "work": "",
                                "personal": ""
                            }
                        ]
                    }
                ],
                "emergency": [
                    {
                        "contact": [
                            {
                                "name": "",
                                "relationship": "",
                                "telephone": [
                                    {
                                        "work": "",
                                        "home": "",
                                        "mobile": ""
                                    }
                                ]
                            }
                        ],
                        "blood_group": ""
                    }
                ],
                "categorization": [
                    {
                        "designation": "",
                        "department": "",
                        "location": "",
                        "joining_date": ""
                    }
                ]
            }
        ],
        "messages": [
            {
                "sender": "Archer<admin@nx-10.ent>",
                "sender_role": "admin",
                "message_type": "broadcast",
                "message": "parking space up for grabs",
                "message_recipients": "all",
                "reply_permitted": "0"
            }
        ],
        "events": [
            {
                "creator": "Travis<ensign@nx-01.ent>",
                "event_title": "",
                "event_description": "",
                "event_time_start": "",
                "event_time_end": "",
                "location": "",
                "invitees": [
                    {
                        "id": "020",
                        "acceptance": "1"
                    }
                ]
            }
        ],
        "settings": [
            {
                "sync_frequency": "0"
            }
        ]
    }
]}

This is a valid json format. I have checked it with http://jsonlint.com/ and using http://braincast.nl/samples/jsoneditor/

see the structure of json value.According to structure the people tag should return count of 2, as it has 2 objects, but it is returning only 1 while parsing.
I am completely out of options. Please help guys.

This is the code i am using for parsing

NSString *textPAth = [[NSBundle mainBundle] pathForResource:@"sync" ofType:@"json"];
NSError *error;
NSString *content = [NSString stringWithContentsOfFile:textPAth encoding:NSUTF8StringEncoding error:&error];    
NSArray *jsonArray = [[content JSONValue] retain]; 
NSLog(@"JSON ARRAY   %@   AND COUNT  %d",[[jsonArray valueForKey:@"updates"] valueForKey:@"people"],[[[jsonArray valueForKey:@"updates"] valueForKey:@"people"]  count]);
  • 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-03T03:43:47+00:00Added an answer on June 3, 2026 at 3:43 am

    I’m not sure why every dictionary is wrapped with an array, when there is only 1 entry (unnecessary), but if you want to parse it you’d want something like this:

    NSDictionary *jsonDict = [[content JSONValue] retain];
    NSArray *updatesArray = [jsonDict objectForKey:@"updates"];
    NSDictionary *updatesDict = [updatesArray objectAtIndex:0];
    NSArray *peopleArray = [updatesDict objectForKey:@"people"];
    NSLog(@"People count: %i", [peopleArray count]);
    for (NSDictionary *peopleDict in peopleArray) {
        //do something
    }
    

    As a side note, if this is your JSON, you’ll want to remove the [arrays] for entries that are not actually arrays. While you can still parse it, it means you’ll have to read the array first then get the dictionary from the objectAtIndex:0, which is totally inefficient and pointless.

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

Sidebar

Related Questions

I have some problem with JSON parsing. When I hit URL, I've got JSON
Hello friends i am having problem in parsing jSON web services data I have
I have a problem with parsing my JSon Data in an Android application. I
I have some problem to order an array by a field of this, here
A] Problem summary: I have JSON data being returned from python to javascript. I
I'm having a recursion problem in Javascript. I have some JSON that I'm passing
I have some JSON scripts that I plan on parsing on the site and
I have some problem with my IIS today. I try to load a .img
I have some problem with my code public IQueryable<PageItems> GetPageById(Guid Id) { var xml
I have some problem with Jquery Autocomplete plugin ( http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/ ) I got it

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.