How to read an external local JSON file in JavaScript?

前端 未结 22 2426
醉酒成梦
醉酒成梦 2020-11-22 02:53

I have saved a JSON file in my local system and created a JavaScript file in order to read the JSON file and print data out. Here is the JSON file:

{"res         


        
22条回答
  •  清歌不尽
    2020-11-22 03:14

    You can use d3.js to import JSON files. Just call d3 on your html body:

    
    

    Then put this on your js scripts:

      d3.json("test.json").then(function(data_json) {
             //do your stuff
      })
    

提交回复
热议问题