Skip to main content
Version: latest - a1.19.x βš–οΈ

JSON

JSON library.

πŸ‘Open Source
This structure is Open Sourced on GitHub. Feel free to make pull requests and suggest changes!
πŸ—ΏStatic Class
This is a Static Class. You can access it's methods directly with .. It is not possible to initialize or create new instances.
tip

nanos world implements a lightweight JSON library from https://github.com/rxi/json.lua.

πŸŽ’ Examples​

local encoded_value = JSON.stringify({ 1, 2, 3, { x = 10 } })
-- Returns '[1,2,3,{"x":10}]'

local decoded_value = JSON.parse('[1,2,3,{"x":10}]')
-- Returns { 1, 2, 3, { x = 10 } }
caution

Note that custom classes (e.g. Vehicle, Vector, Character… etc) aren't stringified with this functions and stringifying them will cause unknown behavior.

πŸ—Ώ Static Functions​

ReturnsNameDescription
string stringifyReturns a string representing value encoded in JSON
any parseReturns a value representing the decoded JSON string

stringify​

Returns a string representing value encoded in JSON

Returns string (the table in JSON)
local ret = JSON.stringify(value)
TypeParameterDefaultDescription
table valuethe table that will become JSON

parse​

Returns a value representing the decoded JSON string

Returns any (the json in table)
local ret = JSON.parse(value)
TypeParameterDefaultDescription
string valuethe JSON that will become a table