问题
I'm creating a dummy JSON value and is trying to show them but the problem is i keep getting this error:
My code snippet is below:
var jsonData = '[{"id":"31370100","machine_name":"GUMACA BRANCH CAM","machine_type":"CAM","operation_start":"05:04:33","operation_end":"09:04:33"}]'
d3.json(jsonData).then((data)=>{
console.log(data);
});
回答1:
d3.json takes a URL as the parameter. As you have the JSON already, you probably just need JSON.parse(), and there is no need to use d3 in this instance. So your code would look something like:
var jsonData = '[{"id":"31370100","machine_name":"GUMACA BRANCH CAM","machine_type":"CAM","operation_start":"05:04:33","operation_end":"09:04:33"}]'
let data = JSON.parse(jsonData);
console.log(data);
来源:https://stackoverflow.com/questions/60963880/d3-json-wont-execute-keeps-getting-error-400