lua -- encode and decode
来源:互联网 发布:知乎是什么 编辑:程序博客网 时间:2024/04/26 11:59
json.encode将表格数据编码为 JSON 字符串。格式:jsonString = json.encode(表格对象)用法示例:local str = json.encode({a=1,b="ss",c={c1=1,c2=2},d={10,11},100})echo(str) -- {"a":1,"b":"ss","c":{"c1":1,"c2":2},"d":[10,11],"1":100}local str = json.encode({1,2,"3",{10,11}})echo(str) -- [1,2,"3",[10,11]]Note: table作为字典使用时,整型键值将被转换为字符串键值local str = json.encode({a=1,[5]=3})echo(str) -- {"a":1,"5":3}Note: table所有键值为整型时,会当作数组看待,空位将转化为nulllocal str = json.encode({[3]=2,[5]=3})echo(str) -- [null,null,2,null,3]~~json.decode将 JSON 字符串解码为表格对象。格式:table = json.decode(string)用法示例:local json = require("framework.shared.json")local tb = json.decode('{"a":1,"b":"ss","c":{"c1":1,"c2":2},"d":[10,11],"1":100}')dump(tb) --[[- "<var>" = {- "1" = 100- "a" = 1- "b" = "ss"- "c" = {- "c1" = 1- "c2" = 2- }- "d" = {- 1 = 10- 2 = 11- }- }]]local tb = json.decode('[1,2,"3",[10,11]]')dump(tb) --[[- "<var>" = {- 1 = 1- 2 = 2- 3 = "3"- 4 = {- 1 = 10- 2 = 11- }- }]]
0 0
- lua -- encode and decode
- H264 encode and decode
- Encode and Decode Strings
- Encode and Decode Strings
- Encode and Decode TinyURL
- Encode and Decode TinyURL
- Encode and Decode TinyURL
- URL Encode and URL Decode
- H264 encode and decode overview
- H264 encode and decode overview
- H264 encode and decode overview
- h264 encode and decode success
- [Leetcode]Encode and Decode Strings
- [LeetCode271]Encode and Decode Strings
- PHP base64url encode and decode
- 535. Encode and Decode TinyURL
- 535. Encode and Decode TinyURL
- 535 Encode and Decode TinyURL
- nand flash控制器
- 提高C++程序运行效率的10个简单方法
- programming-challenges Crypt Kicker (110204) 题解
- session机制详解以及session的相关应用
- Interview Q&A - 合并两个有序数组为一个有序数组(C++)
- lua -- encode and decode
- Java int 与 string的转换
- Java基础 String StringBuffer StringBuilder
- 数字在排序数组中出现的次数
- 基于TBSS的DTI数据处理流程
- 学习老外用webstorm开发nodejs的技巧--代码提示DefinitelyTyped
- Android开发:使用Intent打开电话、短信、邮箱、本地文件等系统应用程序整理大全
- Qt动画框架
- Android CTS测试Fail项修改总结(四)