Can you table.find using JSONDecode?

I’m having a banned audios list which is on github (so i can edit it and it will just be done serverwide instead of having to shutdown, all that stuff) and was wondering if you can do

bannedAudiosTable = game:GetService(“HttpService”):JSONDecode(bannedAudios)
then
table.find(bannedAudiosTable,rawID)

this didn’t work for me, am I doing something wrong

2 Likes

WDYM it didn’t work? Did you get an error or did you get unexpected output?

1 Like

Literally nothing happened - didn’t error at all

1 Like

Trying it ingame instead of in studio it says 403 forbidden

1 Like

403 Forbidden means what it says on the tin; the request can’t be made because the UserAgent (in this case the Roblox server) is unauthorised to query the requested link. If you’re trying to get content from a private repository then you might need to look at authentication and/or repository docs.

We need more context than just a decode and table.find operation here. Please supply relevant bits of code and details about your setup and GitHub repository.

2 Likes

It’s a fully public pastebin link

1 Like

It would be nice to see the code or at least print out what bannedAudiosTable looks like.

1 Like
local bannedAudios = game:GetService("HttpService"):GetAsync("pastebin link but it literally just says 403 whenever i upload it here", false)

bannedAudios = game:GetService("HttpService"):JSONDecode(bannedAudios)
1 Like

Mind putting the actual url or at least a dummy paste that’s formatted the same? Can’t expect anyone to be able to help with how little info is provided.

1 Like

That’s why I replaced it, it was in there but devforum literally wouldnt send it

1 Like

https://pastebin.com/ raw/YKjs2GDK

without the space

I think this is just a case of lack of debugging on your part. Still don’t have enough context but now that you’ve given a usable link I just dropped a quick GET in Studio.

(Also I now understand what you mean by the 403 – it’s for the DevForum, not Studio. I guess the forum doesn’t like PasteBin links.)

local http = game:GetService("HttpService")
local foobar = http:GetAsync("PASTEBIN_LINK_HERE", false)
print(foobar)
local decode = http:JSONDecode(foobar)
print(decode)

image

Anyhow yes, as per the OP, it is something you can do. If it didn’t work for you then, as I said earlier, you need to provide more context such as your current attempt so we can see where you went wrong and how you can fix that attempt. Works fine for me as shown here.

2 Likes

It worked fine for me in-game.
image

Here’s the code I used (it wouldn’t let me use the pastebin link either):

local PASTE_URL = "the link here"
local TEST_AUDIO_ID = 4391535988

local httpServ = game:GetService("HttpService")

local success, data = pcall(httpServ.GetAsync, httpServ, PASTE_URL, false)
if success then
	success, data = pcall(httpServ.JSONDecode, httpServ, data)
	if success then
		print("Success - data:", data)
		print("Found test id:", table.find(data, TEST_AUDIO_ID) ~= nil)
		
	else
		error("JSONDecode threw ERR:", data)
	end
else
	error("HTTP req threw ERR:", data)
end

Hope this helps. Make sure you’re using a number when you do table.find(), realize that the string “4391535988” and the number 4391535988 are different.

2 Likes

Did you test this with my link?

Okay yeah I realised where I went wrong, I’m pretty stupid. I forgot to tonumber(rawID)