d3.js get JSON from url

后端 未结 4 2167
庸人自扰
庸人自扰 2020-12-21 02:01

The situation is that i am trying to get d3 to read a JSON file which is stored in Windows Azure Blob storage. If i paste the url into a browser then the file is downloaded

相关标签:
4条回答
  • 2020-12-21 02:39

    For REST api use d3.request:

    d3.request("api_url/path")
    .header("Content-Type", "application/json")
    .post(function(data) {
       console.log(data);
    })
    
    0 讨论(0)
  • 2020-12-21 02:40

    Should be:

    var url = "http://storageName.blob.core.windows.net/containerName/file.json";
    d3.json(url, function (json) {
        //code here
    });
    
    0 讨论(0)
  • 2020-12-21 02:45

    you'll have to set the Content-Type http header to "application/json" on your blob.

    It can be done programmatically or using the rest API, or using a free utility like cloudberry explorer for azure blob storage.

    0 讨论(0)
  • 2020-12-21 02:52

    Relevant for 2019:

    d3.json("http://127.0.0.1:8080/mydata.json").then( data => {
        console.log(data);
    })
    
    0 讨论(0)
提交回复
热议问题