Skip to content

Function: toJSON() ​

ts
function toJSON(
   target: unknown, 
   separator?: string, 
   depth?: number, 
   maxDepth?: number, 
   circular?: LuaTable<AnyNotNil, boolean>): string;

JSON.stringify alternative for lua data types.

Parameters ​

ParameterTypeDefault valueDescription
targetunknownundefinedValue to stringify as json.
separatorstring" "Separator of each key-value pair after comma.
depthnumber0Current depth of json transformation.
maxDepthnumber7Maximal depth to transform, replace with <depth_limit> otherwise.
circularLuaTable<AnyNotNil, boolean>...Registry of circular items references, return <depth_limit> in case of circular references.

Returns ​

string

Stringified to json value.