I am trying to figure out the best method for accessing nested json data in d3.
So my data looks something like this:
{
"Florida":{"New York": "yellow",
"New Jersey": "blue",
"Pennsylvania": "green",
etc..
And my d3.select function looks something like:
.selectAll("path")
.style('fill', function(d){
return jsondata.state[d.properties.NAME];
of course, var state here is a variable, which should be referring to "Florida", but doesn't.
The way I see it, there are two ways:
Use some of the parsing methods outlined in this post. Namely, the .get() method
Use d3.nest() in some capacity and rolling up my data into an accessible object ahead of the .style function.
What is the best method?