因此,我正在尝试编写一些代码,使用Roblox来获取有关游戏的信息。当我发送一个请求时,我确实得到了数据,但是我想不出在代码中使用数据的方法。因为当我解码的时候,它看起来是这样的:
{
["data"] = ▼ {
[1] = ▼ {
["allowedGearCategories"] = {},
["allowedGearGenres"] = ▶ {...},
["copyingAllowed"] = false,
["createVipServersAllowed"] = false,
["created"] = <creation date>,
["creator"] = ▶ {...},
["description"] = "",
["favoritedCount"] = 0,
["genre"] = "Comedy",
["id"] = <the id>,
["isAllGenre"] = false,
["isFavoritedByUser"] = false,
["isGenreEnforced"] = true,
["maxPlayers"] = 10,
["name"] = <the name>,
["playing"] = 0,
["rootPlaceId"] = <the id>,
["studioAccessToApisAllowed"] = false,
["universeAvatarType"] = "PlayerChoice",
["updated"] = <update date>,
["visits"] = 0
}
}
}
我审查了一些关于它是什么游戏的信息,但这些信息在这里并不重要。重要的是,它在"data“下显示"1”,如果我在代码中键入它,它会将其用作数字。因此,我不能访问列表中除"data“之外的任何内容。
以下是我的代码,如果它有帮助的话:
local universe = Proxy:Get("https://api.roblox.com/universes/get-universe-containing-place?placeid="..placeId).body
local universeDecoded = http:JSONDecode(universe)
local universeId = universeDecoded.UniverseId
local placeInfo = http:JSONDecode(Proxy:Get("https://games.roblox.com/v1/games?universeIds="..universeId).body)
print(placeInfo.data)
另外,对不起,我不知道很多编程单词,所以我会说“在列表中更靠后”之类的话。但我希望你明白我的意思。
发布于 2021-11-13 14:19:28
我自己想出来的。我只是不得不写
print(placeInfo.data[1])
https://stackoverflow.com/questions/69955092
复制相似问题