json table bug or not a bug!

Hi,
Hope you can help with this problem. I’m using json to save a complex data structure. I was having some odd issues with data not being decoded correctly, so I have reduced the problem to the following test-case:

  
local json = require("json")  
  
-- TEST CASE 1  
local data1 = {}  
data1[1] = {}  
data1[1][1] = {}  
data1[1][1].value = 10  
  
local encodedData1 = json.encode(data1)  
  
local decodedData1 = json.decode(encodedData1)  
print(decodedData1[1][1].value)  
  
-- TEST CASE 2  
local data2 = {}  
data2[1] = {}  
data2[1].value = 20;  
data2[1][1] = {}  
data2[1][1].value = 10  
  
local encodedData2 = json.encode(data2)  
  
local decodedData2 = json.decode(encodedData2)  
print(decodedData2[1][1].value)  

TEST CASE 1 succeeds but TEST CASE 2 fails. If line 17 is commented out, TEST CASE 2 passes again. So it seems that if a table node has an entry on that node, any child nodes are ignored.

Is this a problem with my code, or a bug in json?

Thanks for your help,
[import]uid: 87194 topic_id: 26510 reply_id: 326510[/import]

To me it doesn’t seem like that should fail. If you could, please wrap this up into a simple Corona project and submit a bug:

http://developer.anscamobile.com/content/bug-submission [import]uid: 52430 topic_id: 26510 reply_id: 107505[/import]