Consider a use case where you don't have any influence on the structure of data you get from applications, APIs or other business layers to merge your templates for invoices or other reports.

In the following scenario, an invoice should be created based on JSON data from an ERP system. All invoice items are returned as line items plus a last line item that only contains the total price. The following JSON is used as a data source. In line 23-25, you can see a line item that only contains a price. This is the line in the final document we would like to filter out.

[
{
"Id":1,
"Name":"Invoice",
"Orders":[
{
"Id":1,
"OrderItems":[
{
"Id":1,
"Qty":5,
"Product":{
"Id":1,
"Name":"TX Spell .NET",
"Description":"Spell checking component",
"Available":true,
"Price":249.56,
"Serial":"AA6765653"
},
"Price":200.56
},
[...],
{
"Price":4433.44
}
]
}
]
}
]
view raw gistfile1.txt hosted with ❤ by GitHub

As the total price should be calculated using a formula in the template, the last "line item" is not required. The following screenshot shows the template with the repeating block:

Template

After the data is merged into this template as is, the results show the "empty" line displaying only the total value:

Template

In order to remove this empty line, it is not required to manipulate the data. A merge block filter can be used to filter out the empty line. The block OrderItems is receiving a filter on the column Qty. If this field is empty, the row should not be rendered:

Template

The following screenshot shows the filtered results:

Template

You can download the template and the sample JSON here for your own tests.