【发布时间】:2022-06-14 22:45:43
【问题描述】:
我需要将一些信息从 JSON API URL 导入到 Google 表格中。
这是一个例子:
https://api-apollo.pegaxy.io/v1/game-api/race/details/69357391
我已经成功使用 Github 上的 IMPORTJSON 导入基本信息:
https://github.com/bradjasper/ImportJSON/
但现在我面临一种信息(它是一个对象吗?一个数组?),这似乎与平常不同,我发现自己无法导入它。
这是其中的一部分:
{
"id": 969228010,
"raceId": 69357391,
"pegaId": 20042,
"gate": 8,
"pegaAttributes": "{\"id\":20042,\"name\":\"Bajaj\",\"ownerId\":623299,\"raceClass\":1,\"races\":1369,\"win\":504,\"lose\":865,\"energy\":18,\"gender\":\"Male\",\"bloodLine\":\"Campona\",\"breedType\":\"Legendary\",\"speed\":4.95,\"strength\":0.33,\"wind\":3.36,\"water\":1.84,\"fire\":8.83,\"lighting\":6.93,\"position\":4000,\"finished\":true,\"raceTime\":35.855,\"result\":8,\"gate\":8,\"lastSpeed\":22.721521955555556,\"stage\":4,\"isTopSpeedReached\":false,\"bonusStage\":false,\"topSpeed\":22.721521955555556,\"s0\":0,\"j0\":-0.02,\"a0\":0.4982185622222222,\"v0\":20.127527583333332,\"t0\":179.60000000000002,\"gears\":{},\"pb\":0}"**,
"position": 11,
"raceTime": 35.855,
"reward": 0
},
所以如果我想简单地导入“raceId”元素,我会使用 IMPORTJSON:
=ImportJSON("https://api-apollo.pegaxy.io/v1/game-api/race/details/69357391", "/race/registers/raceId", "noHeaders")
但是当尝试从pegaAttributes中导入任何信息时,IMPORTJSON 无法将其识别为单独的。我能做的最好的就是像这样导入整个块:
=ImportJSON("https://api-apollo.pegaxy.io/v1/game-api/race/details/69357391", "/race/registers/pegaAttributes", "noHeaders")
所以"pegaAttributes" 和括号内{ } 之后的一些信息我需要导入。比如raceTime、topSpeed、lastSpeed等属性,如何导入谷歌表格?
任何人都可以提供有关如何执行此操作的任何指示吗?谢谢。
【问题讨论】:
-
您能提供您的预期结果吗?
-
您在另一个 json 中的 json 中查找的内容,因此您必须解析每个 pegaAttributes
标签: google-sheets google-sheets-formula google-sheets-api