Skip to content
You are reading the HappyView v2 docs, which are no longer updated. Read the v3 docs.

JSON API

The json global provides JSON serialization and deserialization. Available in all Lua scripts — queries, procedures, and record/label scripts.

local str = json.encode({ key = "value", items = { 1, 2, 3 } })
-- '{"key":"value","items":[1,2,3]}'

Converts a Lua table to a JSON string.

local tbl = json.decode('{"key": "value"}')
-- tbl.key == "value"

Parses a JSON string into a Lua table. Returns an error if the input is not valid JSON.