cocos2d-x lua table与json的转换
2015-06-06 15:54
513 查看
cocos2d-x lua table与json的转换
version: cocos2d-x 3.61.引入json库
require("src/cocos/cocos2d/json")
2.使用json
function testJson() local beginTime = os.time() local testTable = {} -- [ -- { -- "UserId": "1234567890", -- "Name": "test1", -- "Icon": "www.google.com" -- }, -- { -- "UserId": "1234567890", -- "Name": "test2", -- "Icon": "www.google.com" -- } -- ] for i = 1, 100 do table.insert(testTable, {["UserId"]="123", ["Name"]="test1", ["Icon"]="www.google.com"}) end -- encode local jsonData = json.encode(allUserData) print("user data json:\n" .. jsonData) -- decode testTable = json.decode(jsonData) local endTime = os.time() print("test time: " .. tostring(endTime - beginTime)) end
相关文章推荐
- XML 与 JSON 优劣对比
- 表格标签table深入了解
- Jquery实现的table最后一行添加样式的代码
- 详解Lua中的表的概念及其相关操作方法
- newtonsoft.json解析天气数据出错解决方法
- Lua脚本自动生成APK包
- Lua中的元表(metatable)、元方法(metamethod)详解
- Lua中的metatable介绍
- Lua中ipair和pair的区别
- Lua中的函数精讲笔记
- 浅谈Lua的面向对象特性
- 详解Lua中的变量相关知识点
- Lua脚本语言入门笔记
- Lua脚本调用外部脚本
- Lua 学习笔记之C API 遍历 Table实现代码
- 详解Lua中的if语句的使用方法
- Lua中调用函数使用点号和冒号的区别
- Lua中的闭合函数、非全局函数与函数的尾调用详解
- Lua中强大的元方法__index详解
- Lua面向对象之类和继承浅析