如何将Lua数据表解析为C#字典或其他可用类?(How to parse a Lua data table into C# dictionary or other usable class?)

编程入门 行业动态 更新时间:2024-10-25 18:22:43
如何将Lua数据表解析为C#字典或其他可用类?(How to parse a Lua data table into C# dictionary or other usable class?)

我有这个Lua文件,其中包含以下代码:

options = { ["VR"] = { ["box_mouse_cursor"] = false, ["custom_IPD"] = 63.5, ["custom_IPD_enable"] = true, ["enable"] = false, ["hand_controllers"] = false, ["pixel_density"] = 2, ["prefer_built_in_audio"] = true, ["use_mouse"] = true, } }

我试图找到一个程序集,将其解析为我的.Net Framework 4.5.1 C#项目可用的东西。 LuaInterface是.NET标准2.0项目,不能在.Net Framework 4.5.1中使用,因此不在桌面上。

是否有任何工具可以解析这些信息,并希望再次将其序列化?

I have this Lua file which contains the following code:

options = { ["VR"] = { ["box_mouse_cursor"] = false, ["custom_IPD"] = 63.5, ["custom_IPD_enable"] = true, ["enable"] = false, ["hand_controllers"] = false, ["pixel_density"] = 2, ["prefer_built_in_audio"] = true, ["use_mouse"] = true, } }

I am trying to find an assembly that will parse this into something usable by my .Net Framework 4.5.1 C# project. LuaInterface is .NET standard 2.0 project which can't be used in .Net Framework 4.5.1, so that's off the table.

Are there any tools available that can parse this information, and hopefully serialize it back again?

最满意答案

我会考虑使用Lua来编码您拥有JSON的嵌套表结构。 这将为您提供一种标准格式来写入磁盘和/或轻松传递到另一个代码库。 当你在线搜索( lua table encode json )或者甚至在这里时,有很多选项可供选择。当有类似的问题时,人们正试图踩踏他们的JSON编码/解码Lua库。 例如,这是相反的情况。

I would consider using Lua to encode the nested table structure that you have into JSON. That would give you a standard format to write to disk and/or easily pass into another code base. There are quite a few options available when you search for that online (lua table encode json) or even here on SO people are trying to pedal their JSON encode/decode Lua libraries when similar questions were asked. Here, for example, is the reverse case.

更多推荐

本文发布于:2023-08-01 17:32:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1361309.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   字典   数据表   Lua   parse

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!