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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:01:39+00:00 2026-06-05T17:01:39+00:00

I’m using NSJSONSerialization to parse some JSON from my web service, and I want

  • 0

I’m using NSJSONSerialization to parse some JSON from my web service, and I want to know the most efficient way to lay it out.

Currently I generate the JSON in this format:

[
  {"title":"title Val","description":"description val","appointmentDate":"2012-06-16T00:00:00"},
  {"title":"title Val","description":"description val","appointmentDate":"2012-06-16T00:00:00"},
  {"title":"title Val","description":"description val","appointmentDate":"2012-06-16T00:00:00"}
]

The parser constructs an NSArray where each element is an NSDictionary containing the appointment details (title, description, date).

Now my application actually needs to search the parsed JSON for appointments with dates between some interval so it can show them based on some user action. Currently I just scan the array and retreive any appointments that meet the condition. This is of course O(n). Should I be representing my JSON differently when I want to search on a particular field? Perhaps like this?

{
  "2012-06-16T00:00:00" : {"title":"title Val","description":"description val"},
  "2012-06-18T00:00:00" : {"title":"title val","description":"description val"},
  "2012-06-20T00:00:00" : {"title":"title val","description":"description val"},
}

This way the parser will generate an NSDictionary where each row’s key is the appointment date. Is it more efficient to do this, or can I perform a binary search on an NSArray of NSDictionary objects just as quickly? If the array was searched, it would be necessary to do a [row objectForKey:@"appointmentDate"] in the comparison predicate which could potentially be an expensive operation.

  • 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-05T17:01:41+00:00Added an answer on June 5, 2026 at 5:01 pm

    What about parsing out the appointments and storing them using something like Core Data, with indices set on the fields you want to search over? That might be simpler and faster than trying to optimize and search manually.

    Though if you want to do it manually then yes, building a sorted index keyed by the information you want to search over will give you a more efficient search. So you could have your dictionary that maps NSDate‘s (don’t keep the data in a string format) to the set of appointments on that date, and then you can perform a binary-search over the keyset of the dictionary (make sure it’s properly sorted first!) to identify the range of keys that fall within your search interval. Then you can go into the dictionary and fetch the corresponding appointments.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a French site that I want to parse, but am running into
i want to parse a xhtml file and display in UITableView. what is the
Does anyone know how can I replace this 2 symbol below from the string
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have just tried to save a simple *.rtf file with some websites and
I am reading a book about Javascript and jQuery and using one of 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.