Skip to main content
Version: bleeding-edge 🩸

JSON

JSON library.

πŸ—ΏStatic Class
This is a Static Class. Access it's methods directly with .. It's not possible to spawn new instances.
πŸ§‘β€πŸ’»API Source
This page is auto-generated! The Functions, Properties and Events described here are defined in our GitHub's API Repository! Feel free to commit suggestions and changes to the source .json API files!

πŸŽ’ 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
Returns a string representing value encoded in JSON
Returns a value representing the decoded JSON string

stringify

Returns a string representing value encoded in JSON

β€” Returns (the table in JSON).

local ret = JSON.stringify(value)
TypeParameterDefaultDescription
value Required parameter the table that will become 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

Returns a value representing the decoded JSON string

β€” Returns (the json in table).

local ret = JSON.parse(value)
TypeParameterDefaultDescription
value Required parameter the JSON that will become a 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" }"