Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i turn a string value into a table using http?

How do i turn this string value into a table, it doesnt work for me :( it basically returns a table in string format and i tred using JSONEncode to make it into code? idk help me please!

local Message = game:GetService("HttpService"):GetAsync("http://pastebin.com/raw/R6wy0FNx", true)


while wait(1) do
	Message = game:GetService("HttpService"):GetAsync("http://pastebin.com/raw/R6wy0FNx", true)
	print(game.HttpService:JSONEncode(Message[1]))

end



1 answer

✓ Accepted answer

Your message returns a full string that needs to be parsed, not a JSON table. Each string of numbers needs to be separated and inserted into a table that you can then access.

local http_service = game:GetService("HttpService")

local Message = http_service:GetAsync("http://pastebin.com/raw/R6wy0FNx", true)

local ids = {}
-- Matches each string of numbers and inserts them into a table
for i in string.gmatch(Message, "%d+") do 
	table.insert(ids, i)
end

print(ids[1])

1 comment

0

OMG THANK YOU I WAS THINKING OF STRING MANIPULATION ahhhh thx

This discussion is preserved as it was. New answers, comments, and votes are closed.