I got a JSON file with value’s that got a whitespace in them. like so:
"Project 3":6
I If try to do something in D3.js with the data like so
var meanProject3 = d3.mean(data, function(d) {return d.project 3 });
console.log(meanProject3);
i got the following error:
Uncaught SyntaxError: Unexpected token }
If i try it with nodes that don’t have whitespace it works fine.
I can’t edit the json file. Is there any other way to make this work?
You can’t use dot notation when the property name has special characters such as white space. Try:
Note that property names are case-sensitive.