To add to what Ntero said,
First benchmark.
Second, ideally, Lua should be faster than JSON assuming you could use dofile() to load the code. But due to Apple restrictions and security concerns about running arbitrary downloaded code, we have crippled dofile() for now so you can’t rely on it to work at runtime. There are legitimate reasons to use dofile that don’t involve arbitrary downloaded code (e.g. you writing out your own save-state tables and reading them back in). I think this latter case is technically in Apple’s rules and not really a security threat, but Apple is not forthcoming about these things so we don’t really know. But what we are afraid of is Corona users abusing this if we re-enable dofile() which prompts Apple to overreact and then ban interpreted languages again (the nightmare scenario).
Third, in the absence of dofile(), my theory is given optimal parsers for JSON and Lua, Lua should be faster because the Lua language was designed to be parsed quickly. But you need a Lua parser. There are various things available from the Lua wiki and general searches. (off the top of my head: ‘lua table serialization’, ‘lua pickle’)
Forth, we are planning to add LPeg after the next release. Our current JSON parser (dkjson) has hooks to automatically use LPeg when available which can have dramatic speed improvements. There is a separate project called “Leg” which is designed to parse Lua using LPeg and can solve the lack of dofile(). My personal expectation is that Leg will beat dkjson for this kind of task. But benchmarking is needed.
Finally, if we do eventually relax the dofile() restriction and you are using Lua tables, it will be easy for you to migrate and you will get a good speed boost.
[import]uid: 7563 topic_id: 23933 reply_id: 108531[/import]