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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:00:57+00:00 2026-06-15T07:00:57+00:00

I have a large JSON returned from a rest service and I need to

  • 0

I have a large JSON returned from a rest service and I need to sort it before I can use it.

Example lines:

[{"Time":"1354233600000","Name":"NAN","TagValue":"0","TagValue2":"0"},
{"Time":"1354234500000","Name":"NAN","TagValue":"0","TagValue2":"0.0020288255172466159"},
{"Time":"1354235400000","Name":"NAN","TagValue":"0","TagValue2":"0.0022446943714048121"},
{"Time":"1354236300000","Name":"NAN","TagValue":"0","TagValue2":"0.00014998416164500384"},
{"Time":"1354237200000","Name":"NAN","TagValue":"0","TagValue2":"0"},
{"Time":"1354238100000","Name":"NAN","TagValue":"0","TagValue2":"0.00015631034628383933"},
{"Time":"1354239000000","Name":"NAN","TagValue":"0","TagValue2":"1.1165024734559951E-05"}

There are about 2000 lines like this. I would like to sort them by time and get something like this:

var restData = { "1354234500000":[
                                  {"Name":"NaN",
                                   "TagValue":"0",
                                   "TagValue2":"someFloat"}
                                   {"Name:"NAN,
                                    "TagValue":"0",
                                     "TagVale":"0"}
                                   ],
                   "aNewUnixTimeStamp":[
                                     {..........}
]};

Is there some magic javascript function that I can use to accomplish this?

  • 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-15T07:00:59+00:00Added an answer on June 15, 2026 at 7:00 am
    var myarray = [{"Time":"1354233600000","Name":"NAN","TagValue":"0","TagValue2":"0"},
    {"Time":"1354234500000","Name":"NAN","TagValue":"0","TagValue2":"0.0020288255172466159"},
    {"Time":"1354235400000","Name":"NAN","TagValue":"0","TagValue2":"0.0022446943714048121"},
    {"Time":"1354236300000","Name":"NAN","TagValue":"0","TagValue2":"0.00014998416164500384"},
    {"Time":"1354237200000","Name":"NAN","TagValue":"0","TagValue2":"0"},
    {"Time":"1354238100000","Name":"NAN","TagValue":"0","TagValue2":"0.00015631034628383933"},
    {"Time":"1354239000000","Name":"NAN","TagValue":"0","TagValue2":"1.1165024734559951E-05"}
    

    var result = myarray.reduce(function(res, obj) {
        if (res.hasOwnProperty(obj.Time) === false) {
            res[obj.Time] = [];
        }
        res[obj.Time].push(obj);
        delete obj.Time;
        return res;
    }, {});
    

    You should be aware that since the result is using the timestamps as keys of an object you won’t be able to sort them since objects have no defined order.

    Also .reduce() will need a shim for older browsers. You can use the one provided by MDN.

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

Sidebar

Related Questions

I have a very large integer returned by a json string from my server
How to store large JSON String in cookie ? I have to use cookie
I have a WCF rest service using webHttpBinding that returns JSON result. The problem
So I have a large JSON object i'm returning from the server, then building
I use SBJsonParser for parsing a large json response I query from a server.
I have fairly large set of data returned via AJAX from a page. This
I'm using JSON.NET to deserialize some JSON returned from a web service. Unfortunately, i'm
I have large json data which is contains hundreds thousands elements, now i need
I have a couple of large json files that I need to check for
I have a very large JSON string that I need to parse with in-browser

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.