This operation resolves JavaScript object's key(s) by value(s).
Let's say we have a
person JavaScript object:
person = {
name: 'John',
country: 'Canada',
age: 30
};
And we need to resolve a
name field by
'John' string value.
The following expression does that:
${person<John}
The
'John' value followed by the
< operation is treated as string
as was told in
introduction section.
This expression is evaluated to the following array:
["name"]
I.e. it resolved a
'name' field value by
'John' value from the
person
object.
Object key reverse resolution operation always produces array.
Array can be empty if no matches found.
Also array can contain multiple values.
Object key reverse resolution operation also can be used
dynamically by providing a value as nexl expression:
${person<${myValue}}
In this expression we can provide a
myValue as a variable
and resolve
person's field names dynamically.
myValue can be also a JavaScript array. In that case nexl will resolve all
matching field names.
Let's consider the following expression:
${person<30}
This expression will be evaluated to empty array.
It happens because nexl treats a 30 value as '30' string but
person object
has a 30 of a numeric type.
To solve that we need to provide a 30 numeric value for the
<
operation.
The following expression produces a 30 numeric value:
${@30:num}
Here we are applying a
default value as
'30' string and then
casting it to numeric.
Finally to resolve an 'age' field by 30 numeric value we use the following
expression:
${person<${@30:num}}