Dict Helper
Replace, add or filter for dictionaries or lists a.k.a. JSON objects
Dictionaries, which are basically JSON objects converted into something that a program can better work with and lists are likely the most used to forms of transferring data among programs and between browsers and servers.
Let's set some basic ground work first!
It's like JSON, looks something like this:
{
"users": [
{user1 ... some more JSON},
{user2 ... some more JSON},
{user3 ... some more JSON}
...
]
}
List looks something like this [ 1, 2, 3]. this one just contains numbers. A list of strings (text) would look something like this and contain quotes " around the strings:
[ "Munich", "Berlin", "Frankfurt"]
So good so far. A CSV file with city names in the 1st row and population in the 2nd row would be expressed as a list of list and look like this:
[ [ "Munich", "Berlin", "Frankfurt"], [ "1,45 Millionen", "3,575 Millionen", "736.414"] ]

Replacing fields in dictionaries
As per the above screenshot, we replace the field `first_name` in the JSON / dictionary response of Zendesk with my_new_name. E.g. this (zend1.user) can look like this:
After replacing it looks like this:

Replacing fields in lists
As per the above screenshot, we replace the eights column (item) in a list (in this case in a looper) with my_new_name. E.g. this (
loo1
) can look like this:[
"Berlin",
"Hamburgstraße 12",
20299,
78,
"male",
"student",
"Miller",
"Max"
]
Replacing it returns:
[
"Berlin",
"Hamburgstraße 12",
20299,
78,
"male",
"student",
"Miller",
"my_new_name"
]

The above adds the field age = 27 to the dictionary. E.g. this (zend1.user) can look like this:
Will become after adding age:

The above adds 27 to the list. E.g. this (loo1) can look like this:
[ "Berlin", "Hamburgstraße 12", 20299, 78, "male", "student", "Miller", "Max" ]
Will become after adding:
[ "Berlin", "Hamburgstraße 12", 20299, 78, "male", "student", "Miller", "Max" , 27]
For large list, larger than 50k entries or 5 MB, please use the Spreadsheet helper with action Query spreadsheet, as it can better handle large data.
You can also use a the Jinja filter
selectattr
to filter without having to use an action.will most likely be used a lot for CSV files or e.g. GoogleSheet content that is a list of lists. Please see the section here on filtering CSVs here.
As an example, let's say you want to filter a list of Freshdesk or Zendesk tickets. The response JSON of an API would look like this:
{
"tickets": [
{ticket1 ... some more JSON},
{ticket2 ... some more JSON},
{ticket3 ... some more JSON}
...
]
}
The corresponding connector setup looks like this:

As a list reference in this case, you would provide zen1.tickets in order to only get the list of tickets, because as you can see, within the above JSON object is again a list, indicated by the squared brackets [ ]. So essentially, you could say the above is a JSON object that wraps a list of ticket objects, which are again JSON.
If you want to filter for a particular data record e.g. after pulling all your Zendesk tickets, you want to get all tickets where the requester_id is 12345, you could filter for:
item.requester_id == 12345
An alternative notation which would yield the same result would beHTML
12345 in item.tags
More examples:
"email" in item.profile and item.deleted == False and item.updated >= (unix_timestamp - 3* 24 * 60 * 60)
item.created_date > "{{ convert_datetime(date, '%Y-%m-%d', -30) }}" and item.status == "active" and item.email[-10:] != "locoia.com"
Note that you cannot use the
item
parameter in combination with Jinja, here need you to use Python instead.Last modified 1yr ago