Skip to main content

json

A small JSON encoder/decoder built into every macro. It is available as the global json table and is useful with the Request module.

Methods​

MethodDescription
json.encode(value)Turn a Lua value into JSON text
json.decode(text)Turn JSON text into Lua values

Example​

local body = json.encode({ name = "John", age = 30 })
local response = Request("https://api.example.com/users")
:setHeader("Content-Type", "application/json")
:setBody(body)
:post()
local answer = json.decode(response:getData())
toast("Created user " .. answer.id)