跳到主要内容

Cjson.Decode json转table

🎯功能

json数据转换table。

📜语法

结果 = Cjson.Decode(json文本)

📥参数

参数数据类型解释
json文本字符串待转换的json文本内容。

📤返回

,返回json对应的table。

💡示例

Import "Cjson.lua"
Import "zm.luae"

Dim json, table
json = "{""name"":""紫猫"",""联系"":{""QQ"":[3,4,5,9,1,1,2,2,0]},""url"":""m.zimaoxy.com""}"

// json数据转换table
table = Cjson.Decode(json)
// 输出table内容
TracePrint zm.VarInfo(table)

// table数据转换json
json = Cjson.Encode(table)
// 输出json内容
TracePrint json

📘备注

例子中的zm插件请前往 zm.About 介绍与下载 下载。