Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Decoded table prints nil?

Asked by
OKRPLAY 25
7 years ago

I made a system to Book flights with the Trello API.

wait(1)
local HttpService = game:GetService("HttpService")
ap = require(game.ServerScriptService.TrelloAPI)
BoardID = ap:GetBoardID("REWOT Flights")

bi = ap:GetLists(BoardID)
print(bi)

local json = HttpService:JSONEncode(bi)
print(json)

print(json[1])

In the output "print(json[1])" is "nil" This is the table:

[{"pos":65535,"closed":false,"subscribed":false,"id":"58c02cce4356c6873fc04985", "idBoard":"58c02cc833c86452d2825b77","name":"TestBoard"},{"pos":131071,"closed":false,"subscribed":false,"id":"58c16e98b86cb1d603d793e2", "idBoard":"58c02cc833c86452d2825b77","name":"testboard2"}]

Why is the output nil?

1 answer

Log in to vote
0
Answered by
Querq 20
7 years ago
Edited 7 years ago

The reason your code doesn't work is because you are encoding into JSON when you should be decoding it instead as decoding will turn it into a table that Lua can understand:

local json = HttpService:JSONDecode(bi)

Ad

Answer this question