Hello Team,
We are working on Aspose LINQ Document Template which uses the .docx as input template & generates a PDF based on the JSON data.
But we are facing an issue while iterating 2 JSON array data in a table using the Aspose syntax in the word template.
Input:
"JsonArray1": [
{
"Name": "France"
},
{
"Name": "Italy"
},
{
"Name": "Supranational"
}
]
"JsonArray2": [
{
"Name": "Belgium"
},
{
"Name": "United Kingdom"
},
{
"Name": "Austria"
}
]
Try 1:
Column1 | Column2 | Column3 | Column4 |
---|---|---|---|
<<foreach [item in JsonArray1]>> | <<if [item.indexOf() < 15]>><<[item.Name]>><</if>><</foreach>> | <<foreach [item in JsonArray2]>> | <<if [item.indexOf() < 15]>><<[item.Name]>><</if>><</foreach>> |
Try 2: (Using JsonArray1’s index in elementAt() to get value from JsonArray2 in JsonArray1’s iteration)
Column1 | Column2 | Column3 |
---|---|---|
<<foreach [item in JsonArray1]>> | <<if [item.indexOf() < 15]>><<[item.Name]>> | <<[JsonArray2.elementAt(item.indexOf()).Name]>><</if>><</foreach>> |
Try 3: (Hard coded the index in elementAt() in JsonArray1’s iteration)
Column1 | Column2 | Column3 |
---|---|---|
<<foreach [item in JsonArray1]>> | <<if [item.indexOf() < 15]>><<[item.Name]>> | <<[JsonArray2.elementAt(0).Name]>><</if>><</foreach>> |
Above all 3 tries are not working.
But JsonArray2.elementAt(0).Name is working fine outside of foreach.
Any idea to resolve this issue / scenario ?
Thanks in advance…!