Freemarker Array in ODA

Freemarker array can be confusing to use in ODA (Oracle Digital Assistant). It is hard to find documentation on how to index the content for JSON array. These are the Freemarker syntax I had found to index array for ODA. Hope this helps!

Access First Level

First level JSON array are as follow:

{"results": 
[
{
"index": 0,
"field": "Number",
"value": 1
},
{
"index": 1,
"field": "Name",
"value": “Peter”
}
]
}

The syntax to access the first level array is:

${results.value[selValue.value?number].index}

Access 2nd Level

The JSON format are:

{"results": 
“count”: 2,
“items”:
[
{
"index": 0,
"field": "Number",
"value": 1
},
{
"index": 1,
"field": "Name",
"value": “Peter”
}
]
}

The syntax to access the 2nd level array is:

${results.value.items[selValue.value?number].index}

This will help you access a specific content by index in the array with Freemarker expressions in ODA.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s