函数:ts.json.encode json 串解码

函数名称:json 串解码

函数功能:将 table 格式数据转成 json 格式数据

函数方法

str = json.encode(tb)

参数 类型 必填 说明
tb table 需要解码的数据
返回值 类型 说明
str string 解码后返回的 json 字符串

函数用例

local ts = require("ts")--使用扩展库前必须插入这一句
local json = ts.json--使用 JSON 模块前必须插入这一句
local tb = {
    ["我"] = "五毛",
    ["爱"] = "六块",
    meme = {
        isArray = true,
        1,0,0,4,6,9,5,1,0,0,
    },
    nullvalue = null,
}
--把 table 转换成 json 字符串
local jsonstring = json.encode(tb);
dialog(jsonstring,5)
Copyright 北京帮你玩科技有限公司 2023 all right reserved,powered by Gitbook该文章修订时间: 2024-03-06 17:50:18

results matching ""

    No results matching ""