Hello,
I noticed it’s not possible to encode then decode an array if attributs and values are mixed, for example :
local json = require( “json” )
local data={}
data[1]={}
data[1][1]=10 --value
data[1].a=20 --attribut
local encoded=json.encode(data)
print(encoded) – => [{“1”:10,“a”:20}]
But when decoded by:
data=json.decode(encoded)
It doesn’t work properly :
print(data[1]) – =>table xxxxx
print(data[1][1]) – => nil !!! Why ??? The value 10 is lost!
print(data[1].a) – 20
In fact, if I directly write the array under the following form all its data are preserved:
data={{a=20,10}}
So, is there a way to convert this kind of mixed arrays to a string so that I can save/load them?