我可能错过了这个,但有没有内置的方法将lua表序列化/反序列化为文本文件,反之亦然?
我有一对方法来在具有固定格式的lua表上执行此操作(例如,3列数据,5行).
有没有办法做到这一点与任何LUA表任意格式?
举个例子,给出这个lua表:
local scenes={
{name="scnSplash",
obj={
{
name="bg",
type="background",
path="scnSplash_bg.png",
},
{
name="bird",
type="image",
path="scnSplash_bird.png",
x=0,
y=682,
},
}
},
}
Run Code Online (Sandbox Code Playgroud)
它将被转换为这样的文本:
{name="scnSplash",obj={{name="bg",type="background",path="scnSplash_bg.png",},{name="bird", type="image",path="scnSplash_bird.png",x=0,y=682,}},}
Run Code Online (Sandbox Code Playgroud)
只要文本字符串可以反序列化为空的lua表,就可以以任何方式定义序列化文本的格式.