(函数 (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, : arguments imply different number of rows: 0, 588

Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, : arguments imply differing number of rows: 0, 588

我正在尝试与 NS(荷兰火车公司)的 API 合作。我想以数据帧格式使用它,但是当我 运行 以下代码时出现此错误:

NSspoorkaart <- GET("https://gateway.apiportal.ns.nl/Spoorkaart-API/api/v1/spoorkaart", 
                    add_headers("Ocp-Apim-Subscription-Key" = "f354d5839ec5454fbaf1bc44304b1845"))

JSON <- fromJSON(content(NSspoorkaart, "text"), flatten = TRUE)
Data_NS <- as.data.frame(JSON)

谁能解释一下我做错了什么?

这行得通吗?

NSspoorkaart <- GET("https://gateway.apiportal.ns.nl/Spoorkaart-API/api/v1/spoorkaart", add_headers("Ocp-Apim-Subscription-Key" = "f354d5839ec5454fbaf1bc44304b1845"))

NSspoorkaart.string <- content(NSspoorkaart, as = "text", encoding = "UTF-8")
NSspoorkaart.list <- jsonlite::fromJSON(NSspoorkaart.string)
NSspoorkaart.df <- NSspoorkaart.list$payload$features