I have a table in a table, when I fill the table manually, the tables are set without additional indexes (this is very convenient), but when I fill the table using table.insert (), the index is added.
Example: local Hotel2 = {[“Floors”] = {
[“F1”] = {
[“R1”] = {
TV = 1,Toilet = 2,Decorations = 3
},
[“R2”] = {
TV = 1,Toilet = 2,Decorations = 20
}}}}
Encode: [{"Floors":{"F1":{"R1":{"Decorations":3,"TV":1,"Toilet":2},"R2":{"Decorations":20,"TV":1,"Toilet":2}}}}]
(Manually)
table.insert(Hotel2.Floors,len(Hotel2.Floors) + 1,{["F1"] = {
["R2"] = {
TV = 1,Toilet = 2,Decorations = 3
}
}})
Encode: [{“Floors”:{“F1”:{“R1”:{“Decorations”:3,“TV”:1,“Toilet”:2}},“2”:{“F1”:{“R2”:{“Decorations”:3,“TV”:1,“Toilet”:2}}}}}]
(With insert)
Problem is index “2”
function len return len of table (because “#” not work in this way)
I need table like in Manually, but with table.insert()