Extract List
The Extract List action is one of the actions at your disposal to work with Json data. Extract List enables you to extract a list of values from a JSON or a JSON array.
The action will be able to query/extract data from a JSON input using a JSONPath expression and save it to a variable.
Extract List was previously called Json Mapper to list.
ο»Ώ
The action is used to filter the Json data that we will import in our process for future use.
Input Field 1: βInput JSONβ - Input your JSON object / Array or a data model.
Input Field 2: βQueryβ - The Input Jquery expression for obtaining the desired key value of your Json input.
Output Field: "Output" - Returns a list of values corresponding to the JQuery expression.
How to
The variables need to be adjusted according to your expected result for each process.
Example 1
1. Create a new process and give it a name.
2. Drag the Extract List action to the canvas and link it to the other actions.
- ο»Ώο»Ώ<%JSONin%> will contain the JSon data, the default will use. The variable will be of Type Json, Single Value.
- ο»Ώο»Ώ<%Filter%> will contain the JQuery expression that we will use in order to extract from the Json input data. The variable will be of Type String and Single Value. The query will retrieve the last book in order (notice that the result of the query will be a list with one value). This is the filter for obtaining the last book: $..book[-1:] ο»Ώ<%result%> will be our actions output. The variable will be a List of type Json.
4. Click the Extract List action to access its configurations and add the variables created at the previous space.
5. Save, Validate and Run the process.
6. The process will ask for the inputs, we could leave the defaults as is for now.
7. Click Run.
8. Click Check Instance to view the results.
Further queries
We will continue with further examples of queries by only changing the <%Filter%> and showcasing the returned results for the same Json input, below the examples.
- ο»Ώ<%Filter%> will use $..book[0,1] to obtain the first two books:
ο»Ώ
- ο»Ώ<%Filter%> will use $..book[?(@.isbn)] to filter all books with isbn number:
- ο»Ώ<%Filter%> will use $..book[?(@.price<10)] to filter all books cheaper than 10:
ο»Ώ
1. Create a new process and give it a name.
2. Drag the Extract List action to the canvas and link it to the other actions.
- ο»Ώο»Ώ<%input%> will contain the Json data, the default will use. The variable will be of Type JSon, Single Value.
- ο»Ώ<%filter%> will contain the JQuerry expression that we will use on our data. The variable will be of Type String and Single Value. In this case ..name
- ο»Ώ<%result%> will be our actions output.
4. Click the Extract List action to access its configurations and add the variables created at the previous space.
5. Save, Validate and Run the process.
6. The process will ask for the inputs, we could leave the defaults as is for now.
7. Click Run.
8. Click Check Instance to view the results. We will see that all first names from the json were saved in the variable.