2

我正在遵循谷歌通用表达式语言规范,如果我能做这样的事情,有人可以指导我:

我需要使用 google CEL 编写一个表达式来查找“345”是否在 phone_numbers 列表中。

json :  {"phone_numbers": ["123","234","345"] }

example :  phone_numbers.exist_one("345"); // this does not works .... 

https://github.com/google/cel-spec/blob/master/doc/langdef.md#standard-definitions

4

2 回答 2

1

由于您只是在测试列表中是否存在单个值,因此我建议使用in运算符:

'345' in phone_numbers

如果该宏只能在列表中出现一次,则该exists_one宏非常有用。'345'

于 2019-04-23T15:44:32.217 回答
1

我得到了表达:

phone_numbers.exists_one(r, r=="345")

于 2019-04-09T12:48:16.803 回答