Saving/loading nested tables from/to a file

Anyone loaded nested tables from a file with corona?(I have successfully saved nested tables but have had problems restoring them). I have gotten into the habit of using them for my applications data (yes I know mysql but past experience tells me that Lua Tables are “crazy fast” and mysql tends to slow things down… there are advantages but unless you are working with huge amounts of data… lua tables preform much better)
I have been disappointed that solutions I have used to do this in other implementations of Lua have not worked in Corona and the example for saving tables is inadequate for nested tables.

I know the solution is out there and would hate to reinvent the wheel to do it.

Allen
(Standing on the shoulders of giants whenever possible) [import]uid: 40100 topic_id: 10248 reply_id: 310248[/import]

did u try the json.lua ? [import]uid: 12088 topic_id: 10248 reply_id: 37396[/import]

Allen,

I modified propertybag to allow saving a table as a property. That was as far as I had to go.

For large tables, I’d use the json lib too, it works great. [import]uid: 26049 topic_id: 10248 reply_id: 37410[/import]

Thank you, I got json working (never did get it to restore a nested table but flattened my data structure and made it work).

I once used a bit’o code that serialized a Lua table to… a Lua table… it made retoring it as easy as setting a varible… not sure it can be done that way in corona… can a string be excuted as code…something like

MyTable = [[MyTableAsString]]
(now to figure out why saving and retoring in the simulator works great and the app fails to run on my phone) [import]uid: 40100 topic_id: 10248 reply_id: 37701[/import]

Interesting. So we are allowed to write and then read from files on the iOS devices? [import]uid: 6942 topic_id: 10248 reply_id: 37718[/import]

Should be able too… Although I am writing for android and can’t get it working on the device. [import]uid: 40100 topic_id: 10248 reply_id: 37719[/import]

which json library did you end up using? json.org lists a few and i’m not which one is best [import]uid: 6942 topic_id: 10248 reply_id: 37721[/import]

which json library did you end up using? json.org lists a few and i’m not which one is best [import]uid: 6942 topic_id: 10248 reply_id: 37722[/import]

I tried several versions of json… json4lua is nice but it uses loadstring (which can’t be used in corona) I don’t recall which one I ended up with.(was one that a link was posted for on these forums) All of them seemed to encode and save fine in the simulator, none of them would load a nested table, and I have yet to get this working on my android. [import]uid: 40100 topic_id: 10248 reply_id: 37734[/import]

u can use the json.lua included in the CoronaSDK. /CoronaSDK/SampleCode/Networking/Facebook/json.lua [import]uid: 12088 topic_id: 10248 reply_id: 37739[/import]

I modified propertybag to allow saving a table as a property. That was as far as I had to go.

How did you acheive this? I need to save list data as a table, could you point me in the right direction?

Thanks! [import]uid: 43961 topic_id: 10248 reply_id: 42633[/import]