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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:22:06+00:00 2026-06-18T15:22:06+00:00

I am trying to parse a JSON response using getJSON, and having limited success

  • 0

I am trying to parse a JSON response using getJSON, and having limited success parsing through the objects.

Here is the jquery that I am using, which is returning the appropriate values for the first date in the JSON. I need it to return all of the dates. Is there a particular reason why the following code will not do that?

$.getJSON('result.json', 

                   function(data) {

            var dest = [];

            for (var i = 0; i < data.length; ++i) {

                dates = data[i].dates[i];      
                visitors = data[i].dates[i].items[i];

                dest.push([dates.date,visitors.value]); 

            }
            alert(dest);

        });

Here is the JSON:

[
  {
"type": "visitors-unique",
"dates": [
  {
    "date": "2013-02-10",
    "items": [
      { "value":"117" }
    ]
  },
  {
    "date": "2013-02-09",
    "items": [
      { "value":"427" }
    ]
  },
  {
    "date": "2013-02-08",
    "items": [
      { "value":"403" }
    ]
  },
  {
    "date": "2013-02-07",
    "items": [
      { "value":"227" }
    ]
  },
  {
    "date": "2013-02-06",
    "items": [
      { "value":"289" }
    ]
  },
  {
    "date": "2013-02-05",
    "items": [
      { "value":"246" }
    ]
  },
  {
    "date": "2013-02-04",
    "items": [
      { "value":"236" }
    ]
  }
]
  }
]
  • 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-18T15:22:07+00:00Added an answer on June 18, 2026 at 3:22 pm

    The problem is that you only have one loop when you have nested arrays. Your code will try to get the first date in the first queue, then the second date in the second queue, and so on. To get every date in every queue, you need nested loops:

    $.getJSON('result.json', 
      function(data) {
        var dest = [];
        for (var i = 0; i < data.length; ++i) {
          for (var j = 0; j < data[i].dates.length; j++) {
            dates = data[i].dates[j];      
            visitors = data[i].dates[j].items[0];
            dest.push([dates.date,visitors.value]); 
          }
        }
        alert(dest);
      }
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a JSON file that i'm trying to parse using SBJson. the response
I am trying to parse a JSON response from a server using javascript/jquery. This
I'm trying to parse some JSON coming from an AJAX request using jQuery. Basically,
Hi im getting a error saying that adwhirl cannot parse json response Im trying
I'm trying to parse an NSString that contains JSON data into an NSDictionary using
First: this is my first time using GSON. Trying to parse some JSON, I
I'm trying to parse JSON Using ASIHttpRequset I wrote this code -(void) tryASIHttpRequest{ NSString
I am trying to parse out data from oodle.com api feed using the JSON.NET
I am trying to parse google's API response json formatted string into datatable. I
I'm having a bit of an issue with parsing json with python using 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.