test_list = [Record(topic = nr-dev-01, partition = 0, offset = 10, serialized key size = 3, serialized value size = 873, headers = RecordHeaders(headers = [], isReadOnly = false), key = oregon_ht01, value = {"push_status": "SUCCESS", "push_summary": {"_index": "date_io_kl", "_package": "_zip", "id": "tUz1", "version": 1, "found": "true", "_source": {"Manual": {"Preamble": {"Product_name": {"@value": "Flight manual 101"}, "Version": {"@value": "1.0.0"}, "License_info": {"@value": "LICENSED COPY - February 03 2023"}}}}}}]
我正在尝试查找'key'是否作为test_list的一部分存在,如果是,则获取其值,理想情况下(oregon_ht01)
但它不能说
groovy tst.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
tst.groovy: 1: expecting ')', found 'key' @ line 1, column 133.
e = 1684410534479, serialized key size =
代码段
def keyToFind = 'oregon_ht01'
if (test_list.contains(keyToFind)) {
println("Key $keyToFind found in messages")
} else {
println("Key $keyToFind not found in messages")
}
1条答案
按热度按时间oyxsuwqo1#
假设
test_list
只包含Record类型的对象,并且Record
的所有属性都是公共的,代码如下所示: