smelt.json¶
Availability: Everywhere, including headless mode.
Encode/decode JSON for Lua plugins. Tables with contiguous 1..N integer keys encode as arrays; other tables encode as objects. Use smelt.json.array() when an empty table must encode as an array.
smelt.json.array¶
Create an empty JSON array table. Unlike {}, it encodes as [] while empty.
smelt.json.decode¶
Decode JSON into a Lua value. Returns (value, nil) on success or (nil, err_string) on failure.
smelt.json.encode¶
Encode a Lua value as JSON. Pass { pretty = true } to format with indentation. Tables with contiguous 1..N integer keys encode as arrays; other tables encode as objects. Use smelt.json.array() for an empty array. Raises an error for cycles, nesting deeper than 128 levels, functions and other non-data values, non-finite numbers, and strings that are not valid UTF-8.