【发布时间】:2018-06-28 05:10:32
【问题描述】:
我在网上搜索过,而大多数人都是直接从 url 或本地文件夹中读取 .json 文件 喜欢
console.log("before csv ");
d3.csv("cities.csv", function(data) {console.log(data)});
console.log("before json");
d3.json("flare.json",function(error,data2) {console.log(error, data2)});
虽然目前我的要求是我有一个 json 格式的字符串,比如
{"nodes": [
{"id": "Myriel"},
{"id": "Napoleon"},
{"id": "Mlle.Baptistine"},
{"id": "Mme.Magloire"},
{"id": "CountessdeLo"},
{"id": "Geborand"},
{"id": "Champtercier"},
{"id": "Cravatte"},
{"id": "Count"},
{"id": "OldMan"},
{"id": "Labarre"},
{"id": "Valjean"},
{"id": "Marguerite"},
{"id": "Mme.deR"}
]}
有没有一种方法可以直接将此字符串处理为从 .json 或 .csv 文件中读取的数据?
【问题讨论】:
标签: javascript json d3.js