Packets.getDatabase.listen(function(data)
local decoded = HttpService:JSONDecode(data.data)
local label = addValue("Key")
local titleClone = ReplicatedStorage.client.assets.interface.DatabaseKeyTitle:Clone()
titleClone.Parent = Panel.Pages.Database.Content.Keys.Key
addLabel(data.key, label)
for i, v in decoded do
if type(v) == "table" then
print(v)
local stringBuilder = {}
for i2, v2 in v do
print(i2,v2)
end
else
local label = addValue(i)
local titleClone = titleClone:Clone()
titleClone.Text = string.gsub(i, "_", "")
titleClone.Parent = label
addLabel(v, label)
end
end
end)
in the line with print(v) it only prints things that is a table (as it should), but in the for loop where I loop v and I do print(i2,v2) it prints everything in decoded, also the stuff that is not a table
when you loop through v it doesn’t guarantee that every element of v is also a table / not a table. If you want to do that check you would want to make a recursive function. Otherwise I don’t really understand the problem fully and would ask for output samples
I don’t really understand, because as you can see I am checking if v is a table in the first loop, before I loop v. But it’s still doing this for some reason.
Here is a snippet from the output. Line 66 is print(i2,v2)
okay so, reading back your question, when you do for i2,v2 loop you just print everything that is inside the table, that means it prints values and variables that contains tables. i dont think it bugs out, to fix it printing stuff that isnt a table just put if type(v2) == “table”
I still don’t understand, because I am checking if v is a table, and then looping v if it is. i2 and v2 is then the indexes and values of v (which should be a table).
ye np thats why we were confused, its not printing anything outside. to fix printing every value just put another if type(v2) on the second print amd it should only print tables
tip: never trust data you are getting from, always check the type of data.