json.quote Synchronous

Escape text and enclose it in quotation marks to produce a JSON string token. Use it to produce one complete string value with correct escaping. A table or a full document should go through json.encode.

Syntax
Luau
json.quote(text: string) -> string

Parameters

Function parameters
ParameterTypeDescription
textstringText to encode as a JSON string.

Returns

string

A quoted, escaped JSON string.

Example

Example
Luau
local token = json.quote('Say "hello"')
print(token) -- "Say \"hello\""
print(json.decode(token)) -- Say "hello"
Kawaii documentation