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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:43:54+00:00 2026-05-24T19:43:54+00:00

I have this data coming from a REST method using jquery’s getJSON method. [Date.UTC(2010,0,0,0,0,0,0),

  • 0

I have this data coming from a REST method using jquery’s getJSON method.

"[Date.UTC(2010,0,0,0,0,0,0), 157],[Date.UTC(2010,0,0,0,0,420,1), 157],[Date.UTC(2010,0,0,0,0,420,2), 282],[Date.UTC(2010,0,0,0,0,600,3), 282],[Date.UTC(2010,0,0,0,0,600,4), 125],[Date.UTC(2010,0,0,0,0,900,5), 125],[Date.UTC(2010,0,0,0,0,900,6), 282],[Date.UTC(2010,0,0,0,0,2100,7), 282],[Date.UTC(2010,0,0,0,0,2100,8), 125],[Date.UTC(2010,0,0,0,0,2400,9), 125],[Date.UTC(2010,0,0,0,0,2400,10), 295],[Date.UTC(2010,0,0,0,0,3600,11), 295],[Date.UTC(2010,0,0,0,0,3600,12), 125],[Date.UTC(2010,0,0,0,0,3900,13), 125],[Date.UTC(2010,0,0,0,0,3900,14), 288],[Date.UTC(2010,0,0,0,0,5100,15), 288],[Date.UTC(2010,0,0,0,0,5100,16), 125],[Date.UTC(2010,0,0,0,0,5400,17), 125]"

It comes back as a string. I need to parse it into a two dimensional array. Each item in the array should have a date and a value.

I also have full control over the REST method, so I could change the way the data returns. I’m interested in making this as fast as possible.

Here’s what we are doing now which I think could be improved:

 var jqxhr = $.getJSON(getDataURL, function(dataResult) {
        var result = dataResult;

        result =result.replace(/\]\,\[/g, ']:[');
        result = result.replace(/\)\,/g, ');');

        var tempArray = result.split(':');

        var myarray = new Array();
        myarray[0] = new Array(2); // Make the first element an array of two elements
        for(i = 0; i < tempArray.length; i ++)
        {
          myarray[i] = tempArray[i].split(';');
          myarray[i][1] = myarray[i][1].replace(/\"/g,'');
          myarray[i][1] = myarray[i][1].replace(/\]/g,'');  
          myarray[i][0] = myarray[i][0].replace(/\[/g,'');                             
        }                                                               
    })
  • 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-24T19:43:56+00:00Added an answer on May 24, 2026 at 7:43 pm

    As much as I’m going to get flack for this (eval tends to be a security risk), I would just do

    var myarray = eval("[" + result + "]");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this data from a xml file: <?xml version=1.0 encoding=utf-8 ?> <words> <id>...</id>
I have this big data-entry sort of page, a table kind of layout using
I have this script that collects data from users and I want to check
I have some data coming from other tiers and it represents an EF object.
I have a main thread which should process data coming from several worker threads.
I have an app whose job it is to process data coming from a
I have a listView with some data coming from a server.I want to do
I have data coming from an nvarchar field of the SQL server database via
I have a chunk of data coming from an ajax call. I need to
I have the following python code that expects data coming from the serial port,

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.