JUEL(Java统一表达式语言)中如何遍历嵌套的键值对对象&return某个索引进行求值?

How to traverse a nested key value pair object in JUEL(Java Unified Expression Language) & return a certain index to evaluate against?

我有一个具有重复键值对的对象。我需要遍历它并根据条件评估 index [0] only:

var cells = {"cells": [{"key": "-18", "key1": "-9", "key2": "-51", "key3": "23"}, {"key": 
"-18", "key1": "-9", "key2": "-51", "key3": "23"}, {"key": "-18", "key1": "-9", "key2": "-51", 
"key3": "23"}]};

到目前为止我的代码:

var result = true;

if (cells instanceof java.util.List && !cells.isEmpty()) {
 for (var i = 0; i < cells.size(); i++) {
    var cell = cells.get(i);

    var key = cell.get("key");
    var primeKey = key.get[0];
    if (primeKey) {
        if (parseInt(primeKey) < 5) {
            result = false;
            break;
        }
    } else {
        result = false;
        break;
    }
}
} else {
result = false;
}

return result;

我得到的错误是: 求值时遇到错误:TypeError: Cannot read 属性 "0.0" from undefined (#12)

var primeKey = key.get[0]; 是无意义的,因为 "key" 值对不是要迭代的数组。但是,如果我们简单地将 i 迭代器更改为索引 0 ,就像这样 var cell = cells.get(0); 我们只能根据索引 0 评估条件。不需要遍历整个嵌套循环,因为我们只是与索引 0 进行比较。详情见下文:

var cells = {"cells": [{"key": "-18", "key1": "-9", "key2": "-51", "key3": "23"}, {"key": 
"-18", "key1": "-9", "key2": "-51", "key3": "23"}, {"key": "-18", "key1": "-9", "key2": "-51", 
"key3": "23"}]};

var result = true;

if (cells instanceof java.util.List && !cells.isEmpty()) {
 for (var i = 0; i < cells.size(); i++) {
    var cell = cells.get(0);

    var key = cell.get("key");
    if (primeKey) {
        if (parseInt(primeKey) < 5) {
            result = false;
            break;
        }
    } else {
        result = false;
        break;
    }
}
} else {
result = false;
}

return result;