I’m using the Corona json library.
Here’s an array I have in memory. Output is via “inspect.lua”:
{
[36] = {
inventory = { “garage-gas”, “rocketlauncher”, “newtires”, “flamerthrower”, “steeltires”, “westerntires”, “steelshield”,
},
name = “Fresno”,
shelves = { { 2, 5,
}, { 7,
}, { 4, 6,
}, { 1, 3,
},
},
truck_on_display = “truck-family”,
}
},
}
This is what the JSON encode function spits out for me to save to a file:
{
“36”:{
“inventory”:[“garage-gas”,“rocketlauncher”,“newtires”,“flamerthrower”,“steeltires”,“westerntires”,“steelshield”],
“truck_on_display”:“truck-family”,
“name”:“Fresno”,
“shelves”:[[2,5],[7],[4,6],[1,3]]
},
}
Then, I read it in from that file and in memory it becomes:
{
[“36”] = {
inventory = { “garage-gas”, “rocketlauncher”, “newtires”, “flamerthrower”, “steeltires”, “westerntires”, “steelshield”,
},
name = “Fresno”,
shelves = { { 2, 5,
}, { 7,
}, { 4, 6,
}, { 1, 3,
},
},
truck_on_display = “truck-family”,
}
},
}
The index changed from 36 to “36” which means I have to write a workaround to use a string as the key instead of a number.
This is a bug in the library unless there’s something I don’t understand.