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 comment