Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Json Multi-Array

Posted on 2013-10-22
2
Medium Priority
?
395 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 83

Accepted Solution

by:
leakim971 earned 2000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…
Suggested Courses

886 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