Skip to content

JSON

Reference for the json API.

Functions

json.encode

Encodes a table into an instance of json.

lua
---@param data table
function json.encode(data): json

json.decode

Decodes an instance of json into a table.

lua
---@param json json
function json.decode(json): table

Types

json

lua
---@param indent? integer
function json:dump(indent?): string

Examples

lua
local data = {a=1, name='test'}
local json = json.encode(data)
print(json:dump()) -- '{ "a": 1, "name": "test" }'