JSON
From Legacy Roblox Wiki
Jump to navigationJump to search
JSON is a data storage format.
Currently in ROBLOX you can use an manipulate it through the RbxUtility library, which provides the following relevant functions:
Example
How to save complex statistics to a player:
local Utils = assert(LoadLibrary("RbxUtility")) -- The library we need
local character_stats = { -- Some epic stats.
money = 123456;
title = "1337 h4x04";
is_epic = true;
awards = {
kills10 = true;
died20 = false;
};
}
local JSON = Utils.EncodeJSON(character_stats) -- Convert the table to a string
local player = game.Players:FindFirstChild("Telamon") -- Find someone to save the stats to
if player then
player:WaitForDataReady() -- Make sure it's safe to save first
player:SaveString("Stats", JSON) -- Save the stats
end