I am using the code snippet at the bottom of this post in my code. It is from Rob Miracle. Very good code, by the way.
I am loading a small json file that contains a series of x,y points. All works well in the simulator. It reads the data in fine and maneuvers the object on screen across those x,y coords.
But, when same file is built and transferd to the iPad to test, it fails when processing the code related to the json file. I tested for 2 days now and I am certain the ‘loadtable’ function itself is not the issue, because, if I strip the code down to just the ‘load table’ function there are no issues on the iPad. But as soon as I try to access any field/value from that table it seems like the rest of the code below that code does not execute.
Even if I try just running an empty loop using the #theJsonTable… it fails on the iPad, but still runs well on the simulator.
I am assuming the simulator is more tolerant of things then the actual iPad is. Anything to do with that json table seems to have a bad effect on the iPad.
Anyone have similar issues using json on the iPad?? Or does anyone have any insight on this issue?
function loadTable(filename)
path = system.pathForFile( filename, system.DocumentsDirectory)
local contents = “”
local myTable = {}
local file = io.open( path, “r” )
if file then
– read all contents of file into a string
local contents = file:read( “*a” )
myTable = json.decode(contents);
io.close( file )
return myTable
end
return nil
end
[import]uid: 148857 topic_id: 26778 reply_id: 326778[/import]