Syntax
json.quote(text: string): stringArguments
| Name | Type | Description |
|---|---|---|
text | string | String to quote. The function reads this argument with string type checking. |
Returns
| Name | Type | Description |
|---|---|---|
quoted | string | Complete JSON string literal including the opening and closing quote. Quotes, backslashes, common control characters, and bytes below 0x20 are escaped. |
Description
Escapes a string using Real's JSON string escaping rules and returns a complete quoted JSON string literal.
Call it with 1 parameter(s): text. The argument table explains which values are required and which ones only refine the behavior.
It returns quoted (string). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Convert a string into a complete quoted JSON string literal.
local source = "Real Docs" .. string.char(10) .. [[Documentation "A"]]
local quoted = json.quote(source)
print(quoted)