Writing Lua values out as JSON. The API dump the reference is generated from goes through this, so what a script writes out is encoded the way the engine's own data is.
trx.json.encode(value)
Writes a value out as JSON, on one line. Keys come out in sorted order, so
the same value encodes the same way twice and a file that is committed and
diffed only moves when what it holds does.
A table is written as a list where it holds entry 1, or holds nothing at all, and as an object otherwise. A function, a handle and anything else with no JSON of its own is left out.
Parameters:
Returns: string. The JSON text.
Example:
trx.json.encode({ name = "wolf", ids = { 7, 8 } })
-- {"ids":[7,8],"name":"wolf"}