In this article:
Filters allow users to better manage which data transactions ultimately get sent into their system by reducing any unwanted or redundant messages. Customers can set up filters for JSON and XML source files within the Flow configuration screen. that are in JSON or XML format. Simple JSON filter or a more advanced JSONata filter, as well as an Xpath filter within the flow configuration screen for any flow that uses a JSON or XML document as the source file type.
Setting up a JSON Filter
Using basic key/value pairs or JSONata expressions, users can quickly define which JSON files get processed while discarding the rest.
You can set up a JSON filter by navigating to your flow configuration screen.
Click the panel labeled Filters to reveal the JSON Filter options. By default Disabled is selected.
In the dropdown, you can enable JSON filtering by selecting either of the following options:.
1) Simple: This filter mode allows users to filter by defining a key-value pair. For the key column, fill in the simple path to the field. A simple JSON path to a property within a nested object is written with a “.” between every object key from JSON root to the target field. You would then put what value you would expect for the key. Any files that match that criteria will be processed by Chain.io and can be found in the “Search” screen where you can view the flow executions. Any file that does not meet the criteria will be filtered out and discarded (not visible or processed in portal.chain.io).
Simple Mode JSON Filter Example: If someone wants to filter all JSON files where the carrier is NOT Maersk they could setup a simple JSON filter as such:
Example Input:
Simple JSON filter:
2) Advanced: This allows you to take advantage of using JSONata expressions to build more complex filtering logic. To learn more about the JSONata you can visit: https://docs.jsonata.org/overview and to practice writing your own JSONata expressions using your own data, you can use https://try.jsonata.org/
Advanced JSONata filter:
In the previous example, the correct way to filter on carrier name using the advanced mode would be to write this JSONata expression: carrier.name = "Maersk A/S"
Setting Up An XPath Filter
Using XPath expressions, customers have the ability to filter data within their source files from being processed by the Flow execution. To add an XPath Filter, navigate to your flow configuration and open the Filters panel:
Select Enabled from the dropdown then click the Add button to add a new Xpath Filter Expression:
In the field the appears add your XPath expression.