5. Object property resolution operation

To resolve an object property just use a dot in the expression.
For example:
${person.name}
In this example first we are resolving a person object and then it's name property.

If the person object doesn't such property expression will be evaluated to undefined value.

You can also resolve deeper object properties:
${person.address.street}
Property name can be also provided dynamically as nested nexl expression:
${person.${prop}}
In this example the ${prop} expression must be evaluated to the primitive data type or array of primitives.
In case of array nexl will multiple the result according to the prop array.

If the ${prop} expression is evaluated to undefined value nexl will ignore this property resolution operation.

To avoid such situation apply an empty default value for ${prop} expression:
${prop@}
The final expression will look like this:
${person.${prop@}}
That means if the prop variable is undefined, nexl will apply an empty string value for the property resolution.
On the other hand the person object doesn't have an empty string field.
As a result the ${person.${prop@}} expression will be evaluated to undefined value.

_this_ and _parent_ variables

nexl has two following reserved ( virtual ) variables which can be used in JavaScript object declaration:
_this_
_parent_
_this_ variable point to the current object level and _parent_ points to upper object level.
They can be accessed in nexl expressions.

Let's say we have the following JavaScript object declaration which contains ${_this_} and ${_parent_} references:
dirs = {
    rootDir: '/home/projects',
    homeDir: '${_this_.rootDir}/urban',

    subDirs: {
        logsDir: '${_parent_.homeDir}/backups'
    }
};
If we evaluate the ${dirs} expression to get dirs object we will get the following:
{
  "rootDir": "/home/projects",
  "homeDir": "/home/projects/urban",
  "subDirs": {
    "logsDir": "/home/projects/urban/backups"
  }
}

Watch a demo