Syntax
json.quote(text: string): stringArguments
| Name | Type | Description |
|---|---|---|
text | string | Text value used by the operation. |
Returns
| Name | Type | Description |
|---|---|---|
quoted | string | Complete JSON string literal. |
Description
Wraps and escapes text as a complete 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 plain text into a complete quoted JSON string.
local source = "Real Docs" .. string.char(10) .. "Documentation"
local quoted = json.quote(source)
print(quoted)