Skip to content

smelt.json

Tier: Host - Available in every runtime, including headless mode.

Visibility: Public - Stable Lua API intended for user config and plugins.

Encode/decode JSON for Lua plugins. Tables with contiguous 1..N integer keys encode as arrays; other tables encode as objects.

smelt.json.decode

fun(text: string): any, string?

Decode JSON into a Lua value. Returns (value, nil) on success or (nil, err_string) on failure.

smelt.json.encode

fun(value: any, opts: table?): string

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.