函数:json.encode json 串解码

函数名称:json 串解码

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

函数方法

str = json.encode(tb)

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

函数示例

local json = require("json")
local my_table = {
    name = "John Doe",
    age = 30,
    hobbies = {"read", "game", "travel"}
}
local str = json.encode(my_table)
dialog(str,5000)
local tmp = json.decode(str)
dialog(tmp.name,5000)
Copyright 北京帮你玩科技有限公司 2024 all right reserved,powered by Gitbook该文章修订时间: 2025-04-28 17:14:10

results matching ""

    No results matching ""