json. escape Synchronous
Escape text for inclusion inside a JSON string without adding surrounding quotation marks. Use it only when assembling the contents of a string token yourself. For an entire value or document, json.quote or json.encode handles the surrounding syntax.
Luau
json.escape(text: string) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
text | string | Unescaped text to process. |
Returns
stringEscaped string contents. Use json.quote when a complete JSON string token is needed.
Example
Luau
local escaped = json.escape('first line\n"quoted"')
print(escaped)
print(json.unescape(escaped))