查找数组中对象元素的值

我有一个插入表,该表包含Plate Values

我该如何迭代表来确保以下内容为真

function table.contains(table, element)
  for _, value in pairs(table) do
    if value == element then
      return true
    end
  end
  return false
end

我的当前表插入

for k, v in pairs(returnVehicleData) do
    platesAvailable = v.plate
    newTable =  {['plate'] = platesAvailable}
    table.insert(vehiclePlateTable, newTable)
end

返回的数据

[{"plate":"47QVS009"},{"plate":"86KIE632"}]

我想检查两个对象冒号后面的后续值。

点赞
用户14262787
用户14262787

我最终做了这个,并且让它工作了

newValueTable = {}
for Key = 1, #tabledPlate, 1 do
    table.insert(newValueTable, tabledPlate[Key].plate)
end

因为这些元素是另一个更大的数据表的一部分,它们实际上并不返回为字符串。但还是谢谢Coordinate Newton的建议。

2020-09-12 20:41:14