I need help with JSON table

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:
Capture1

but I want it to be like this:
Capture2

JSON table:
Capture3

How do I write a table in json so that it is like my expected result?

I don’t know if this is what you’re looking for but I found this page:

So something like-

{
"cd": [stuff],
"ab":[stuff],
}

Wait hold on, I’m stupid, I didn’t read the last part. Ignore everything above.

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

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.