【问题标题】:flattened json file using javascript / coffee with d3.json使用带有 d3.json 的 javascript/coffee 的扁平化 json 文件
【发布时间】:2014-03-27 02:17:09
【问题描述】:

我正在尝试扁平化并合并 json 中的值,这是 json

https://api.github.com/repos/wesm/D3py/commits

我已成功提取每个位置使用下面的此咖啡代码

d3.json "https://api.github.com/repos/wesm/D3py/commits", (data) -> 
  console.log data[0].commit.author.name
  return 

但是当我尝试在下面做类似的事情时,我希望看到 name 数组,但什么也没得到,

 d3.json "https://api.github.com/repos/wesm/D3py/commits", (data) -> 
  names = (name for name in data.commit.author.name)
  console.log names
  return

【问题讨论】:

    标签: javascript json d3.js coffeescript


    【解决方案1】:
    names = (entry.commit.author.name for entry in data)
    

    【讨论】:

    • 谢谢! @meetamit 这很好用,我花了 3 个小时!!
    猜你喜欢
    • 2021-03-31
    • 2017-09-18
    • 1970-01-01
    • 1970-01-01
    • 2021-05-24
    • 2011-11-15
    • 2021-02-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多