Passer au contenu principal
Version: bleeding-edge 🩸

JSON

JSON library.

🗿Static Class🧑‍💻API Source

🎒 Examples

(JSON.stringify) Stringifies a Lua table
local encoded_value = JSON.stringify({ 1, 2, 3, { x = 10, y = Vector(1, 2, 3) }, "he" })
-- Outputs "[1,2,3,{"x":10,"y":"Vector(1.0, 2.0, 3.0)"},"he"]"
(JSON.parse) Parses a JSON string into a Lua table
local decoded_value = JSON.parse('[1,2,3,{"x":10,"y":"Vector(1.0, 2.0, 3.0)"},"he"]')
-- Outputs "the table { 1, 2, 3, { x = 10, y = Vector(1, 2, 3) }, "he" }"
note

Note that custom classes (e.g. Vehicle, Character, Prop... etc) or functions are not supported to be stringified and will be nullified.

Structs (e.g. Vector, Rotator, Color... etc) are supported and will be parsed/stringified properly!

🗿 Static Functions

ReturnsNameDescription
stringstringifyRetourne une chaîne représentant la valeur encodée en JSON
anyparseRenvoie une valeur représentant la chaîne JSON décodée

stringify

Retourne une chaîne représentant la valeur encodée en JSON
local ret = JSON.stringify(value)

Parameters

TypeParameterDefaultDescription
tablevalue Required parameter the table that will become JSON

Returns

TypeDescription
stringthe table in JSON
JSON.stringify Examples
Stringifies a Lua table
local encoded_value = JSON.stringify({ 1, 2, 3, { x = 10, y = Vector(1, 2, 3) }, "he" })
-- Outputs "[1,2,3,{"x":10,"y":"Vector(1.0, 2.0, 3.0)"},"he"]"

parse

Renvoie une valeur représentant la chaîne JSON décodée
local ret = JSON.parse(value)

Parameters

TypeParameterDefaultDescription
stringvalue Required parameter the JSON that will become a table

Returns

TypeDescription
anythe json in table
JSON.parse Examples
Parses a JSON string into a Lua table
local decoded_value = JSON.parse('[1,2,3,{"x":10,"y":"Vector(1.0, 2.0, 3.0)"},"he"]')
-- Outputs "the table { 1, 2, 3, { x = 10, y = Vector(1, 2, 3) }, "he" }"