Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Cannot parse JSON when trying to decode a JSON Table?

Asked by
Akkoza 0
4 years ago
Edited 4 years ago

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

0
Your code works just fine for me. crywink 419 — 4y
0
It worked for me when I wrapped that table with "[[]]". Yuuwa0519 197 — 4y
0
When I try it doesn't work. I don't know why. Akkoza 0 — 4y
0
I figured out why, I had it formatted differently than that of the one I put here, thanks Yuuwa Akkoza 0 — 4y

1 answer

Log in to vote
0
Answered by
Akkoza 0
4 years ago

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

Ad

Answer this question