Skip to main content

Arguments

any
required
Value ที่จะ encode. nil, booleans, numbers, strings, tables และ json.null ถูกจัดการโดยตรง. Unsupported Lua types จะถูก encode เป็น null เว้นแต่ errorOnUnsupported เป็น true.
EncodeOptions
Optional encode options. boolean toggle pretty output. number เปิด pretty output ด้วยจำนวน spaces ที่ clamp เป็น 0.16. string เปิด pretty output ด้วย indent นั้น. table สามารถตั้ง pretty, sortKeys, emptyTableAsArray, errorOnUnsupported, encodeInvalidNumbersAsNull, maxDepth และ indent.

Returns

string
Encoded JSON string. Encoding errors จะ throw เป็น Luau errors.

Types

EncodeOptions

ควบคุมการทำให้เป็นอนุกรมและการจัดรูปแบบ JSON

ตัวอย่าง

Encode JSON-compatible values โดยใช้ json.array เมื่อ empty array ต้องคงเป็น array.