This guide includes information regarding:
- how to implement lists in the general JSON format
- how to use JSON lists while writing a ruleset
How to implement lists in the general JSON format
In some cases, the content of a data field is not a single value, but many values. Think about the different features of a product. To incorporate them into your data, instead of listing them all in separate data fields, you also could use a JSON list to enumerate the different features one after another.
This would look like this:
In your data, *Features* is the key of the JSON list and inside the Square brackets, you can find the seperate feature values enumerated.
This is the general structure of your JSON if you have a field with multiple values.
How to use JSON lists while writing a ruleset
The first step to working with this JSON list inside your generated content would be to create a property (let's call it
DATA_Features) accessing this JSON element by name, like #features in the mapping expression.
This first drafted form of the property would return the whole content of the list like this:
LTE, WLAN, Bluetooth, Kamera
The next step would be to expand the property by designating the feature values as a list.
This can be done by adding a list function to the mapping expression,
The Text engine now regards to the JSON values as a list of values, so different operations can be used to sort or filter its content:
Access in other properties' mappingExpressions and truthExpressions
$Features returns the first Feature from the list: LTE
Access in sentences
[DATA_Features.Best(1)] prints the first Feature from the list to the sentence: LTE
[DATA_Features.Random(2)] prints 2 randomly chosen Features from the list to the sentence: LTE, Kamera
For a complete explanation of all available list operations please refer to our ATML3-Expressions documentation.