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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:17:46+00:00 2026-05-24T23:17:46+00:00

I have data being pulled in from various sources, each returning some form of

  • 0

I have data being pulled in from various sources, each returning some form of JSON or similar, although, differently formatted each time. I need to get them all into one array, but I can’t figure out how to do it.

The first set is an array like this:

[
 Object {id="70", type="ab", dateadded="12345678"},
 Object {id="85", type="ab", dateadded="87654321"}, ... more items ...
]

The second set is being pulled in from Facebook, and is like this:

[
 Object {id="12341234234", created_time="12345678"},
 Object {id="567856785678", created_time="87654321"}, ... more items ...
]

So, I need to alter the second set so that it has ‘type’, and it has ‘dateadded’ instead of ‘created_time’, and then I need to get this all into one array so it can be sorted on ‘dateadded’.

How can I do 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-05-24T23:17:48+00:00Added an answer on May 24, 2026 at 11:17 pm

    Assuming you have actual valid JSON instead of what you quoted above:

    var jsonOld = '[{"id":"70","type":"ab","dateadded":"12345678"},{"id":"85","type":"ab","dateadded":"87654321"}]',
        jsonNew = '[{"id":"12341234234","created_time":"12345678"},{"id":"567856785678","created_time":"87654321"}]';
    

    Then first parse these values into actual Javascript arrays:

    var mainArr = JSON.parse(jsonOld),
        newArr = JSON.parse(jsonNew);
    

    (If you already have actual Javascript arrays instead of JSON strings then skip the above step.)

    Then just iterate over newArr and change the properties you need changed:

    for (var i = 0, il = newArr.length; i < il; i++) {
        newArr[i].type = 'ab';
        newArr[i].dateadded = newArr[i].created_time;
        delete newArr[i].created_time;
    }
    

    And concatenate newArr into mainArr:

    mainArr = mainArr.concat(newArr);
    

    And sort on dateadded:

    mainArr.sort(function(a, b) { return a.dateadded - b.dateadded; });
    

    This will result in:

    [{"id":"70","type":"ab","dateadded":"12345678"},
     {"id":"12341234234","type":"ab","dateadded":"12345678"},
     {"id":"85","type":"ab","dateadded":"87654321"},
     {"id":"567856785678","type":"ab","dateadded":"87654321"}]
    

    See example

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

Sidebar

Related Questions

EDIT: Ok I have some data (A ton of data) being pulled from a
I have a question regarding the some data which is being transfered from one
i have the following data being pulled out from a databasse that is being
I have table rows of data in html being filled from a CGI application.
I have data coming from the database in the form of a DataSet .
Technologies: C#, .Net, Winforms I have a main form that pulls data from a
I have a form where a user can select a rating from 1-5. Each
im trying to add items to jagged array's, the data is being pulled from
I'm working with some data which is being retrieved from my database. It's placed
I have a model being populated by my data layer and then I have

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.