使用NLua反序列化Lua表

我在网上搜索了许多资料,特别是这个链接:

表序列化

但是它们都不起作用。

我正在尝试以下最简单的表:

下面是INPUT.LUA文件的内容

{
    ["customers"] =
    {
        ["name"] = "John Smith",
        ["age"] = 45
    },
    {
        ["name"] = "Susan Jones",
        ["age"] = 34
    },
}

其中 x = input.lua

我在Lua中有以下代码:

if(type (x) == "table" then
   dostuff()
else
  return "this is not a table"
end

但是,所有的反序列化都只返回了 "this is not a table"。

我现在正在编写自己的反序列化器,它将必须处理所有的转义字符、开始表、跟踪嵌套表和值的类型 - 为什么???

难道我是个白痴 - 我哪一部分的表序列化程序不理解吗??

点赞