lua中的Serialization
2015-07-22 16:52
295 查看
--Serialization 写成流可以和网络进行联通 function serialize( o ) if type( o ) == "number" then io.write(o) elseif type(o) == "string" then io.write("[[",o,"]]") end end a = 'a, "hello lua" \\' --print(string.format("%q",a)) --lua 5.1中的 [=[...]=] --print([=['a, "hello lua" \\']=]) --保存无环的table function n_serialize( o ) if type(o) == "number" then io.write(o) elseif type(o) == "string" then io.write(string.format("%q",o)) elseif type(o) =="table" then io.write("{\n") for k,v in pairs(o) do io.write(" ",k,"=") n_serialize( v ) io.write(",\n") end io.write("}\n") end end n_serialize{a =12,b ='lua'} --lua可以帮助你去扩展,简单的串行化; --lua脚本和txt
相关文章推荐
- lua中的table
- 一个lua文件如何调用另一个lua文件的变量?
- Lua 语言 15 分钟快速入门(转)
- 【经典BUG】exe与dll同时使用Lua的一个内存崩溃异常
- SLua 中使用 Lua 5.3 的编译工程
- c++ 使用pbc 解决lua 解析protobuf 问题
- lua笔试
- lua迭代器和仿制药for
- 编译安装lua 时 lua.c:67:31: fatal error: readline/readline.h: No such file or directory
- lua的API
- [转]LUA 学习笔记
- LuaBridge
- 将Lua嵌入IOS程序
- LUA 配置 运行 异常的备忘录
- Algorithms—150.Evaluate Reverse Polish Notation
- c++ lua文章list
- c++ lua文章list
- Lua 5.1 参考手册
- Lua 5.1 参考手册
- lua——基础语法