我遵循谷歌常用表达式语言规范,如果我能做这样的事情可以指导我:
我需要编写一个表达式来查找使用谷歌CEL在phone_numbers列表中是否“345”。
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
我得到了表达式:
phone_numbers.exists_one(r, r=="345")
由于您只是测试列表中是否存在单个值,我建议使用in
运算符:
'345' in phone_numbers
如果exists_one
只能在列表中出现一次,那么'345'
宏非常有用。