Arguments
any
required
Value to encode. nil, booleans, numbers, strings, tables, and json.null are handled directly. Unsupported Lua types encode as null unless errorOnUnsupported is true.
EncodeOptions
Optional encode options. json.encodePretty reads the same options as json.encode, then forces pretty to true. Without options, it uses a two-space indent. A number sets the indent width clamped to 0.16, a string sets the indent text, and a table can set sortKeys, emptyTableAsArray, errorOnUnsupported, encodeInvalidNumbersAsNull, maxDepth, and indent.
Returns
string
Readable formatted JSON string. Encoding errors are thrown as Luau errors.