【问题标题】:Importing JSON that starts with an array导入以数组开头的 JSON
【发布时间】:2020-03-24 13:14:31
【问题描述】:

我正在尝试使用 excel 来导入和显示 JSON。我已经为大多数 JSON 工作了。使用这个特定的 JSON,它以一个数组开头,我不知道 parseOptions 语法如何首先寻址和数组,然后是对象。我已经成功使用 =IMPORTJSON("url", "object to call") 我想显示“[0]/metadata/last_name”对于每个数组对象。

这是我的代码:

=IMPORTJSON("https://api.sleeper.app/v1/draft/547633764530618368/picks","[0]/metadata/last_name")

这是我的 JSON:

[
 {
  "round":1,
  "roster_id":null,
  "player_id":"4866",
  "picked_by":"448639868432543744",
  "pick_no":1,
  "metadata":{
    "years_exp":"2",
    "team":"NYG",
    "status":"Active",
    "sport":"nfl",
    "position":"RB",
    "player_id":"4866",
    "number":"26",
    "news_updated":"1577679319834",
    "last_name":"Barkley",
    "injury_status":"",
    "first_name":"Saquon"
 },
 "is_keeper":null,
 "draft_slot":1,
 "draft_id":"547633764530618368"
 },
 {
  "round":1,
  "roster_id":null,
  "player_id":"4046",
  "picked_by":"341432375512702976",
  "pick_no":2,
  "metadata":{
    "years_exp":"3",
    "team":"KC",
    "status":"Active",
    "sport":"nfl",
    "position":"QB",
    "player_id":"4046",
    "number":"15",
    "news_updated":"1583891151374",
    "last_name":"Mahomes",
    "injury_status":"",
    "first_name":"Patrick"
 },
 "is_keeper":null,
 "draft_slot":2,
 "draft_id":"547633764530618368"
 },
 {
  "round":1,
  "roster_id":null,
  "player_id":"4881",
  "picked_by":"539512871341760512",
  "pick_no":3,
  "metadata":{
    "years_exp":"2",
    "team":"BAL",
    "status":"Active",
    "sport":"nfl",
    "position":"QB",
    "player_id":"4881",
    "number":"8",
    "news_updated":"1580608524794",
    "last_name":"Jackson",
    "injury_status":"Probable",
    "first_name":"Lamar"
 },
 "is_keeper":null,
 "draft_slot":3,
 "draft_id":"547633764530618368"
 }

【问题讨论】:

  • 我没用过IMPORTJSON。你在哪里得到它?我主要使用VBA-JSON
  • 不确定您想要输出什么,但Power Query 可以解析以url 开头的 JSON,然后将记录列表转换为表格。
  • Excel 2020 没有 Power Query。我使用了 IMPORTJSON,它是 excel 的一个函数。

标签: arrays json excel xpath


【解决方案1】:

好的,我想出了第一部分。代码如下:

\\ =IMPORTJSON("https://api.sleeper.app/v1/draft/547633764530618368/picks","0/metadata/first_name") \\

但现在我试图让单元格通过数组的 FOR 循环运行。所以它从 0 开始(如在 0/metadata/first_name 中),但是如何在循环中设置它以便每个单元格增加数组编号?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-30
    • 1970-01-01
    • 2011-06-29
    相关资源
    最近更新 更多