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.

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

Parameters

Function parameters
ParameterTypeDescription
textstringUnescaped text to process.

Returns

string

Escaped string contents. Use json.quote when a complete JSON string token is needed.

Example

Example
Luau
local escaped = json.escape('first line\n"quoted"')
print(escaped)
print(json.unescape(escaped))
Kawaii documentation