gpt4 book ai didi

javascript - 如何使用嵌套数组对象访问 d3 json 文件中的值

转载 作者:行者123 更新时间:2023-11-30 05:41:01 24 4
gpt4 key购买 nike

之前我使用的是具有以下格式的 json 文件:

[{"lat":43.788458853157117,"lng":-79.282781549043008,"category":"volunteer","name":"Rita","url":"", "description":"xxx is a member of 13"},{"lat":43.7,"lng":-79.4,"category":"organization","name":"TCAN","url":"http://tcan.ca","description":"Lorem ipsum"}]

现在我正尝试从 Drupal 站点生成 json 文件并获得以下结构。我如何引用最低级别的字段。我查看了使用 d3.net 的示例,但没有找到任何适用的示例。

{
"organizations": [
{
"member": {
"field_category": "organization",
"body": "A network of organizations in Toronto devoted to climate change mitigation and adaptation.",
"URL": "xxx.ca",
"title": "Toronto Climate Action Network",
"field_lat": 43.7,
"field_long": -79.4
}
},
{
"member": {
"field_category": "abc",
"body": "xxx.",
"URL": "",
"title": "yyy",
"field_lat": 43.7,
"field_long": -79.28
}
}
]
}

最佳答案

假设您的数据存储在变量data中:

var bottom = data.organizations.map(function(d) { return d.member; });

关于javascript - 如何使用嵌套数组对象访问 d3 json 文件中的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20807883/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com