JSON
JSON library, useful for sending data from Client's Package to WebUI environment
tip
nanos world implements a lightweight JSON library from https://github.com/rxi/json.lua.
info
Tip: This structure is Open Sourced at https://github.com/nanos-world/nanos-world-lua-lib. Feel free to push merge requests and suggest changes!
Usageβ
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β
Returns | Name | Description |
---|---|---|
string | stringify(table) | Returns a string representing value encoded in JSON |
any | parse(string) | Returns a value representing the decoded JSON string |