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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:44:56+00:00 2026-06-07T22:44:56+00:00

I have a JSON with a say 10k records in it. Each record has

  • 0

I have a JSON with a say 10k records in it. Each record has a timestamp of the form ‘2011-04-29’.
Now I have a client side array (let’s call it our calendar) with arrays of the form –

['2011-04-26', '2011-05-02', 'Week 1', '2010 - 11']
...

The goal is to assign a week number to each record’s timestamp. I could use a classical linear search to accomplish this, but with 10k+ json records and close to 300 weeks in the calendar, this soon becomes tedious.

What would you recommend?

PS – I need the calendar because the weeks here are not the actual week of the year, but defined else where.

Would there be a more efficient way of doing this if i converted the strings to Date.getTime()?

  • 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-07T22:44:58+00:00Added an answer on June 7, 2026 at 10:44 pm

    With only 300 weeks, my approach would be to introduce an intermediate lookup object, matching each possible timestamp to the appropriate week. Just use a simple loop that will generate:

    {
        '2011-04-26': 1,
        '2011-04-27': 1,
        // ...
        '2011-05-02': 1,
        '2011-05-03': 2,
        '2011-05-04': 2,
        // ...
    }
    

    Those values would simply be indices in your calendar array.

    Then you can assign your 10K of records to a calendar week with a simple lookup in this object.

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

Sidebar

Related Questions

I have JSON string that has nested objects with dynamic names that vary each
When you have a multi-tiered object like a json object that say has 3
Let's say I have a JSON set of events, each with a start time
Let's say i have this JSON array $json = '[[1258765200,12350],[1259370000,13000],[1259974800,11840],[1260579600,16359],[1261184400,14230],[1261789200,07406],[1262394000,12846],[1262998800,11204],[1263603600,10234]]'; Where the first value
Let's say i have this json data. How to transform the tags to a
For example lets say I have a JSON object that contains states and cities.
lets say I have two methods in my controller to support both json and
I am trying to build JSON from two fields. Say, I have a list
Say i have this short code: item = Item.find(params[:id]) render :json => item.to_json but
I have a basic jQuery selector question. Let's say I'm parsing JSON and generating

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.