Skip to main content

Аргументы

any
обязательно
Value для encoded. nil, booleans, numbers, strings, tables и json.null обрабатываются напрямую. Unsupported Lua types encoded как null, если errorOnUnsupported не true.
EncodeOptions
Optional encode options. json.encodePretty читает те же options, что и json.encode, затем принудительно ставит pretty в true. Без options используется two-space indent. number задает indent width с clamp до 0.16, string задает indent text, а table может задавать sortKeys, emptyTableAsArray, errorOnUnsupported, encodeInvalidNumbersAsNull, maxDepth и indent.

Возвраты

string
Readable formatted JSON string. Encoding errors выбрасываются как Luau errors.

Типы

EncodeOptions

Управляет сериализацией и форматированием JSON.

Пример

Encode JSON-compatible values как readable formatted JSON с pretty output forced on.