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.
Luau
json.quote(text: string) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
text | string | Text to encode as a JSON string. |
Returns
stringA quoted, escaped JSON string.
Example
Luau
local token = json.quote('Say "hello"')
print(token) -- "Say \"hello\""
print(json.decode(token)) -- Say "hello"