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.

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

Parameters

Function parameters
ParameterTypeDescription
textstringRaw text to escape.

Returns

string

The 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

Example
Luau
local inside = json.escape('say "hello"')
print(inside)
print('"' .. inside .. '"')
Kawaii documentation