json_encode
json_encode(table) converts a Lua table or value into a JSON string. Uses SpyWeb’s built-in high-performance JSON engine, handling nested tables, arrays, booleans, and nulls automatically.
Signature
Section titled “Signature”json_encode(table)
syncParameters
Section titled “Parameters”| Param | Type | Description |
|---|---|---|
table |
any | The Lua value to encode |
Returns
Section titled “Returns”| Value | Type | Description |
|---|---|---|
| json | string | JSON-encoded string |
Example
Section titled “Example”local payload = { url = "https://example.com", options = { waitUntil = "networkidle2" }}local body = json_encode(payload)local resp = http_post("https://api.rendering-service.com/render", body, {["Content-Type"]="application/json"})See Also
Section titled “See Also”- json_decode - Parse JSON string to Lua table