Hello!
So, I’m connecting my game to Trello and a list in it.
Each card has its description.
And this description is a table.
For example like that local tableTest = {["Test1"]="123",["Test2"]="456"}.
When I try to print some value like print(tableTest[“Test1”]), it works fine but when I try to do it in a for i loop (which loops through cards, I get nil).
If I print card’s description I get the same table as above, but when I try to get a value from it, it’s just nil.
Do you know how would I fix that?
Thank you!
EDIT: Noticed, that it returns as a string. Is there a way to make it as a table?
I’m guessing it may be in JSON because it’s in string-form?
You could try decoding it into a table: local Data = game:GetService("HttpService"):JSONDecode(string)
Well, I’ve tried multiple options,this is one of them
for i,v in pairs(TrelloAPI:GetCardsInList(List)) do
local tableDesc = {}
table.insert(tableDesc,v.desc)
local json = HttpService:JSONEncode(v.desc)
print(json)
local jsonDec = HttpService:JSONDecode(json)
print(v.desc)
for key,val in pairs(jsonDec) do
print(val)
end
end
for i,v in pairs(TrelloAPI:GetCardsInList(List)) do
local tableDesc = {}
table.insert(tableDesc,v.desc)
local jsonDec = HttpService:JSONDecode(json)
print(v.desc)
for key,val in pairs(jsonDec) do
print(val)
end
end
Try this, I noticed that in your previous code snippet, you encoded it and then decoded it, which didn’t do much.
I’ve solved the issue. Basically, Json was encoding a string instead of a table, so it should be like that: {"Test1":"123","Test2":"456"} and if you encode that, you can use it as a table.