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

Cannot parse JSON when trying to decode a JSON Table?

So I'm working on a game, and I'm using a JSON table in a StringValue, that passes through this code

function grabData(object)
	local dataTable
	if object:WaitForChild("Data",0.001) then
		local dataTable = game:GetService("HttpService"):JSONDecode(tostring(object.Data.Value))
	end
	if dataTable == nil then return nil else return dataTable end
end

and the JSON Table is

{"Destructable":true,"Health":20,"State":"Crate1","Holdable":true}

But I keep getting the can't parse JSON error

4 comments

0

Your code works just fine for me.

0

It worked for me when I wrapped that table with "[[]]".

0

When I try it doesn't work. I don't know why.

0

I figured out why, I had it formatted differently than that of the one I put here, thanks Yuuwa

1 answer

Solved by Yuuwa0519 Had to wrap the JSON Table with '[[]]'

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