I want to verify if a certain JSON key exists in the JSON datastore that I use inside the Word template.
This is the JSON:
{
"dummy": "text",
"customers": {
"label": {
"name": "name-of-the-group"
},
"label2": {
"name": "name-2-of-the-group"
}
}
}
In Word I tried to use
<<if [_data.customers.contains(“label2”)]>> Label2 is present<<else>>Label2 is missing<</if>>
<<if [_data.customers.contains(“label3”)]>> Label3 is present<<else>>Label3 is missing<</if>>
but then it prints
Label2 is missing
Label3 is missing
although label2 is present.
And when I try to use
<<if [_data.customers.label3 != null]>> Label3 is present<<else>>Label3 is missing<</if>>
then I get
<<if [_data.customers.label3 != Error! Can not get the value of member 'label3' on type 'class com.aspose.words.internal.zzjq'. null]>> Label3 is present<<else>>Label3 is missing<</if>>
Can anyone provide me with an example how to check if a JSON key exists?