Anyone know of an easy way to parse a Lua datastructure in C# or with any .Net library? This would be similar to JSON decoding, except for Lua instead of javascript.
At this point it looks like I'll need to write my own, but hoping there's something already out there.
Thanks to both of you, I found what I was looking for using LuaInterface
Here's a datastructure in Lua I wanted to read ("c:\sample.lua"):
Here's some sample code reading that Lua datastructure using LuaInterface:
And here's what that sample code writes to the console:
To figure out how to use the library I opened up the LuaInterface.dll in Reflector and google'd the member functions.
I haven't looked at this one yet, saving a link for now: http://www.youpvp.com/blog/post/LuaParse-C-parser-for-World-of-Warcraft-saved-variable-files.aspx
LuaInterface is unfortunately only packaged to run on x86, so I was looking at alternatives. Here's the source:
You may (or may not) find what you need among Lablua projects.
In any case, do not hesitate to ask your question on Lua mailing list.
LsonLib can parse Lua data structures, manipulate them and serialize the result back to Lua text. Full disclosure: I am the author. It's pure C# and has no dependencies.
Given:
Basic usage:
(it's actually a fairly straightforward port of a JSON library we use internally, hence it has quite a few features and might have some JSON traces left over)
What Alexander said. The lab is the home of Lua, after all.
Specifically, LuaInterface can allow a Lua interpreter to be embedded in your application so that you can use Lua's own parser to read the data. This is analogous to embedding Lua in a C/C++ application for use as a config/datafile language. The LuaCLR project might be fruitful at some point as well, but it may not be quite as mature.