d3.json() won't execute. keeps getting error: 400

喜你入骨 提交于 2020-04-17 22:54:18

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!