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

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​

ReturnsNameDescription
stringstringify(table)Returns a string representing value encoded in JSON
anyparse(string)Returns a value representing the decoded JSON string