JSON

json.unescape

将转义的 JSON 字符串内容转换回纯文本。

语法

json.unescape(text: string): string

参数

名称类型描述
textstring操作使用的文本值。

返回值

名称类型描述
textstring未转义的文本值。

说明

将转义的 JSON 字符串内容转换回纯文本。

使用 1 个参数调用: text。参数表会说明哪些值必填,哪些值只用于细化行为。

返回 text (string)。使用返回表区分成功值、nil 结果和可恢复错误。

示例

恢复转义或引用的 JSON 字符串内容。

local quoted = json.quote("Real Docs" .. string.char(10) .. "Docs")
local restored = json.unescape(quoted)

print(restored)