Skip to content

JSON Utilities

General-purpose JSON encode/decode under the util namespace.

Usage

lua
-- Encode a Lua value to JSON
local json = util.json.encode({ name = "test", value = 42, tags = {1, 2, 3} })
print(json)  -- {"name":"test","value":42,"tags":[1,2,3]}

-- Decode JSON to a Lua value
local obj = util.json.decode('{"temp": 300, "status": "ok"}')
print(obj.temp)    -- 300
print(obj.status)  -- "ok"

Function Reference

FunctionReturnsDescription
util.json.encode(value)stringEncode Lua value to JSON string
util.json.decode(str)anyDecode JSON string to Lua value

⚠️ This documentation was AI-generated and may contain inaccuracies. Please submit pull requests with corrections as needed.