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

Using JSON to Decode and Encode tables?

Asked by
devMe 20
9 years ago

Im saving tables and have done so by encoding and decoding them.

I am using

local hs = game:GetService("HttpService") local balloons = hs:JSONEncode(table)

But when I do that, I get an error: Can't parse JSON

0
is table nil? RM0d 305 — 9y
0
What is `table`? We can't exactly help you without knowing that. adark 5487 — 9y

1 answer

Log in to vote
2
Answered by
RM0d 305 Moderation Voter
9 years ago
print (game.HttpService:JSONEncode({["Gold"]=25,["XP"]=50}))

{"Gold":25,"XP":50}

print (game.HttpService:JSONDecode('{"Gold":25,"XP":50}')) 

table

print (game.HttpService:JSONDecode('{"Gold":25,"XP":50}')["Gold"])

25

Ad

Answer this question