json. escape Synchronous
Escape text for the inside of one JSON string token. Use this only when assembling a string token yourself; json.quote and json.encode produce the surrounding quotes for you.
Luau
json.escape(text: string) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
text | string | Raw text to escape. |
Returns
stringThe escaped string contents without surrounding quotation marks.
Usage notes
Control characters, quotation marks, and backslashes are escaped. The result by itself is not a complete JSON value.
Example
Luau
local inside = json.escape('say "hello"')
print(inside)
print('"' .. inside .. '"')