[SOLVED] JSON problems - maybe formatting

Hi, I have a file with some json data - but somehow it only loads the first line when i try to loop through the table. I am maybe missing something here and I am a newbie when it comes to json.

Lua code:

json = require "dkjson"  
  
local jsonFile = function( filename, base )  
  
 -- set default base dir if none specified  
 if not base then base = system.ResourceDirectory; end  
  
 -- create a file path for corona i/o  
 local path = system.pathForFile( filename, nil )  
  
 -- will hold contents of file  
 local contents  
  
 -- io.open opens a file at path. returns nil if no file found  
 local file = io.open( path, "r" )  
  
 if file then  
 -- read all contents of file into a string  
 contents = file:read( "\*a" )  
 io.close( file ) -- close the file after using it  
 end  
  
 return contents  
end  
  
-- local t = json.decode ( jsonFile( "test.json" ), 1, nil)  
local t = json.decode ( jsonFile( "data/Wildebeest\_1\_Sleep.json" ), 1, nil)  
  
--local t = json.decode( )  
  
for k,v in pairs(t) do  
  
 print (k, v )  
  
end  

Sample of Json with 3 entries:

{"refid":1,"img":"wildebeest1\_shd\_1","yref":3.8000000000000114,"xref":6.975,"yscale":1,"xscale":1,"alpha":1,"y":150.8,"x":7.85,"rotation":0},  
{"refid":1,"img":"wildebeest1\_shd\_1","yref":3.8000000000000114,"xref":6.975,"yscale":1,"xscale":1,"alpha":1,"y":150.8,"x":7.85,"rotation":0},  
{"refid":1,"img":"wildebeest1\_shd\_1","yref":3.8000000000000114,"xref":6.975,"yscale":1,"xscale":1,"alpha":1,"y":150.8,"x":7.85,"rotation":0}  

[import]uid: 81188 topic_id: 23989 reply_id: 323989[/import]

Yepp, there where problems with the formatting.

I could recommend this nifty tool for checking json syntax…

http://www.jsoneditoronline.org/

Joakim [import]uid: 81188 topic_id: 23989 reply_id: 96678[/import]