JSON
JSON library.
🗿Static Class
This is a Static Class. Access it's methods directly with
.
. It's not possible to spawn new instances.Examples​
local encoded_value = JSON.stringify({ 1, 2, 3, { x = 10, y = Vector(1, 2, 3) }, "he" })
-- Returns '[1,2,3,{"x":10},"he"]'
local decoded_value = JSON.parse('[1,2,3,{"x":10},"he"]')
-- Returns { 1, 2, 3, { x = 10 }, "he" }
note
Note that custom classes (e.g. Vehicle, Character, Prop... etc) or functions are not supported to be stringified and will be nulified.
Structs (e.g. Vector, Rotator, Color... etc) are supported and will be parsed/stringified properly!
Static Functions​
Returns | Name | Description | |
---|---|---|---|
string | stringify | Returns a string representing value encoded in JSON | |
any | parse | Returns 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)
Type | Parameter | Default | Description |
---|---|---|---|
table | value | the 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)
Type | Parameter | Default | Description |
---|---|---|---|
string | value | the JSON that will become a table |