k = {
messageCode = 200,
result = {
data = [
{id=7,language="Hindi"},
{id=8,language="Tamil"}
]
}
}
How do I access language here?
I have been trying this way
print(k.result.data.language)
Your attempt to access the table is almost right, but your table is malformed.
k = {
messageCode = 200,
result = {
data = {
{
id = 7,
language = "Hindi"
},
{
id = 8,
language = "Tamil"
}
}
}
}
print(k.result.data[1].language)
print(k.result.data[2].language)
k.result.data is an array (numeric lua table), so you have to iterate or access them by number.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With