Accessing a two dimensional JSON array with Javascript

arrays, javascript, json

Solution

Use `JSON.parse`:

var population = JSON.parse(data);
alert(population[1][0]);

JsFiddle: http://jsfiddle.net/6CGh8/

Problem

Possible Duplicate: I have a nested data structure / JSON, how can I access a specific value? I am using the US Census API and end up with a two dimensional json array from a jQuery.get() request. My result (data) looks like this: `[["P0010001","NAME","state","county","tract"], ["2703","Census Tract 4001.01","17","119","400101"], ["5603","Census Tract 4001.02","17","119","400102"], ["4327","Census Tract 4002","17","119","400200"]]` It looks exactly like a two dimensional javascript array, but I cannot access it like one when I try: ``` var population = data; alert(population[1][0]); ``` Is there a way to convert the json array into a javascript array, or to convert it to a string, which could then be put into an array?

Original source

Related problems