I’m making a whitelist system that gets a table from a website, decodes it, and then checks if a userid is in that table. However, I have no idea how to write a table in json. I’m getting this result:
but I want it to be like this:
JSON table:
How do I write a table in json so that it is like my expected result?
Redluo
(Redluo)
June 3, 2023, 12:52pm
#2
I don’t know if this is what you’re looking for but I found this page:
Data for the accordion table must be created in a specific JSON format. This structure should describe the table, column headers, rows and cells, custom CSS classes to apply to each object, as well as any scripts to trigger or child tables. Table The...
Est. reading time: 2 minutes
So something like-
{
"cd": [stuff],
"ab":[stuff],
}
Wait hold on, I’m stupid, I didn’t read the last part. Ignore everything above.
zilibobi
(Checkmate)
June 3, 2023, 1:03pm
#3
Both of them are the same. Unless you are converting it into a string, it does not matter. Here’s what I mean:
local t = {
[1] = "a",
[2] = "b",
[3] = "c"
}
local t2 = {
"a",
"b",
"c"
}
print(t[1]) -- prints "a"
print(t2[1]) -- prints "a"
print(t) --[[ prints
{
[1] = "a",
[2] = "b",
[3] = "c"
}
]]
print(t2) --[[ prints
{
[1] = "a",
[2] = "b",
[3] = "c"
}
]]
If you want to see if a user id is in a table, do this:
if table.find(list, userid) then
--- user is whitelisted
end
Do note that this function only works with arrays.
1 Like
system
(system)
Closed
June 17, 2023, 1:03pm
#4
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.