语法
json.quote(text: string): string参数
| 名称 | 类型 | 描述 |
|---|---|---|
text | string | 操作使用的文本值。 |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
quoted | string | 完整的 JSON 字符串文字。 |
说明
将文本包装并转义为完整的 JSON 字符串文字。
使用 1 个参数调用: text。参数表会说明哪些值必填,哪些值只用于细化行为。
返回 quoted (string)。使用返回表区分成功值、nil 结果和可恢复错误。
示例
将纯文本转换为完整的带引号的 JSON 字符串。
local source = "Real Docs" .. string.char(10) .. "Documentation"
local quoted = json.quote(source)
print(quoted)