JSON

Extract List

11min
Document image
ο»Ώ
ο»Ώ

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.

ο»Ώ

Overview

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.

Document image
ο»Ώ
Document image
ο»Ώ
  • ο»Ώο»Ώ<%JSONin%> will contain the JSon data, the default will use. The variable will be of Type Json, Single Value.
JSON
ο»Ώ
  • ο»Ώο»Ώ<%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.

Document image
ο»Ώ

5. Save, Validate and Run the process.

6. The process will ask for the inputs, we could leave the defaults as is for now.

Document image
ο»Ώ

7. Click Run.

8. Click Check Instance to view the results.

Document image
ο»Ώ

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:
Document image
ο»Ώ

ο»Ώ

  • ο»Ώ<%Filter%> will use $..book[?(@.isbn)] to filter all books with isbn number:
Document image
ο»Ώ
  • ο»Ώ<%Filter%> will use $..book[?(@.price<10)] to filter all books cheaper than 10:
Document image
ο»Ώ

ο»Ώ

Example 2ο»Ώο»Ώο»Ώο»Ώ

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.

Document image
ο»Ώ
Document image
ο»Ώ
  • ο»Ώο»Ώ<%input%> will contain the Json data, the default will use. The variable will be of Type JSon, Single Value.
JSON
ο»Ώ
  • ο»Ώ<%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.

Document image
ο»Ώ

5. Save, Validate and Run the process.

6. The process will ask for the inputs, we could leave the defaults as is for now.

Document image
ο»Ώ

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.

Document image
ο»Ώ

Updated 16 Feb 2024
Doc contributor
Doc contributor
Doc contributor
Did this page help you?