Solved

Json Multi-Array

Posted on 2013-10-22
2
342 Views
Last Modified: 2013-10-22
I have the below string which I belive is correct for a multi-array string.

var chartData = { "Name":  [{ country: "United States", visits: 9252 }, { country: "China", visits: 1882 }], "Name2": [{ country: "Japan", visits: 1809 }, { country: "Germany", visits: 1322 }, { country: "United Kingdom", visits: 1122 } ]};

Open in new window


Now that the above is done how do I break out the array I need ie Name2?
0
Comment
Question by:crundle32
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39592964
Test page : http://jsfiddle.net/6x2e5/

var chartData = { "Name":  [{ country: "United States", visits: 9252 }, { country: "China", visits: 1882 }], "Name2": [{ country: "Japan", visits: 1809 }, { country: "Germany", visits: 1322 }, { country: "United Kingdom", visits: 1122 } ]};
var array_Name2 = chartData.Name2;
alert('there is ' + array_Name2.length + 'objects in array_Name2' );

Open in new window

0
 

Author Closing Comment

by:crundle32
ID: 39592992
thank you
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question