util.table.encode
Shared
Encodes a table into a JSON string
Syntax
local result = util.table.encode(input)Parameters
| Type | Name | Description |
|---|---|---|
table | input | Table to encode |
Returns
| Type | Name | Description |
|---|---|---|
string | bool | result | Encoded JSON string on successful execution, false otherwise |
Examples
local data = {name = "John", age = 25}
local result = util.table.encode(data)
core.engine.print("info", result) -- '{"name":"John","age":25}'local colors = {"red", "green", "blue"}
local result = util.table.encode(colors)
core.engine.print("info", result) -- '["red","green","blue"]'local coords = {100, 200, 300}
local result = util.table.encode(coords)
core.engine.print("info", result) -- '[100,200,300]'local settings = {enabled = true, debug = false}
local result = util.table.encode(settings)
core.engine.print("info", result) -- '{"enabled":true,"debug":false}'