When creating a new index for lua-table; you need to provide them in a square boxes:
myarray = {
value = {
["my-password"] = {
value = "12345"
}
}
}
Question
I'm trying to replace the following lua logic:
myarray = {}
myarray.value = {}
myarray.value["my-password"] = {}
myarray.value["my-password"].value = "12345"
myarray.value.user.value = "11111"
with:
myarray = {value = {user= {value="11111}, "my-password"= {value = "12345"}}}
But I keep getting the above error message. Line 37 is the line where I'm consolidating the array initialization into one line.
I can't see where the bug is. Thanks
Solution
When creating a new index for lua-table; you need to provide them in a square boxes:
myarray = {
value = {
["my-password"] = {
value = "12345"
}
}
}
OTHER TIPS
You missed the brackets:
myarray = {value = {["my-password"] = {value = "12345"}}}
-- ^ ^
foo.bar
is the syntactic sugar of foo["bar"]
, the brackets can't be omitted in the latter form.