json.quote Synchronous

Produce one complete JSON string token from text. It is handy when you need a quoted value for a small constructed fragment; use json.encode for a whole table or document.

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

Parameters

Function parameters
ParameterTypeDescription
textstringRaw text to quote and escape.

Returns

string

Escaped text enclosed in double quotation marks.

Example

Example
Luau
local token = json.quote('say "hello"')
print(token)
assert(json.decode(token) == 'say "hello"')
Kawaii documentation