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

What is the purpose of JSON encoding a table and decoding it I thought roblox did that for us?

Asked by 5 years ago
Edited 5 years ago

In a data store I don't understand why I would Encode and Decode a table when roblox already did it for us is there any benefit to doing so?

1 answer

Log in to vote
0
Answered by 5 years ago

You can't save a string with a size larger than 260,000 characters for a single key, so one may want to check the size of their JSON encoded table before saving it. For example:

local t = {}

for i = 1, 2^14 do
    t[i] = true
end

local json_t = HttpService:JSONEncode(t)

if #json_t > 260000 then
    -- handle error
else
    data:SetAsync("test", t)
end

There is no other major reason that you should care about encoding your datum to JSON before saving it unless you need to check something before the save occurs.

Ad

Answer this question