[英]Importing JSON that starts with an array
I am trying to use excel to import and show a JSON.我正在尝试使用 excel 导入并显示 JSON。 I've got this working for most JSONs.我已经为大多数 JSON 工作了。 With this particular JSON, it starts with an array and I don't know how the parseOptions syntax to address and array first and then objects.I have successfully used =IMPORTJSON("url", "object to call")
I want to display the '[0]/metadata/last_name' for each array object.使用这个特定的 JSON,它以一个数组开头,我不知道 parseOptions 语法如何首先寻址和数组,然后是对象。我已经成功使用=IMPORTJSON("url", "object to call")
我想显示每个数组对象的“[0]/metadata/last_name”。
here is my code:这是我的代码:
=IMPORTJSON("https://api.sleeper.app/v1/draft/547633764530618368/picks","[0]/metadata/last_name")
Here is my JSON:这是我的 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"
}
Okay, I figured the first part out.好的,我想出了第一部分。 code looks like this:代码如下所示:
\\\\ =IMPORTJSON(" https://api.sleeper.app/v1/draft/547633764530618368/picks ","0/metadata/first_name") \\\\ \\\\ =IMPORTJSON(" https://api.sleeper.app/v1/draft/547633764530618368/picks ","0/metadata/first_name") \\\\
But now I'm trying to have the cells run through a FOR Loop of the array.但现在我试图让单元格通过数组的 FOR 循环。 So it starts at 0 (as in 0/metadata/first_name), but how do I set it in a loop so that each cell increased the array number?所以它从 0 开始(如在 0/metadata/first_name 中),但是如何在循环中设置它以便每个单元格增加数组编号?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.