15min

Json Mapper To List

The Json Mapper To List action is one of the actions at your disposal to work with Json data. Json Mapper To 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.

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 JSon Mapper To 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 Json Mapper To 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 JSon Mapper To 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 Json Mapper To 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 27 Apr 2022
Did this page help?
Yes
No