Referencing data of objects, lists, arrays - how to pass data dynamically

Referencing data of dictionaries (dicts or objects), lists, arrays - how to pass data dynamically

Referencing data such as dictionaries (dicts), lists, arrays, or CSV column-style data is one of the more tricky tasks for business users who are not familiar with data objects in programming, but necessary to automate more complex flows and logic. It is pretty similar to complex spreadsheet functions. We try our best to make it as easy and intuitive as possible by providing you with a wealth of documentation as well as examples in the Flow Automation Marketplace.

We rely on one of the industry standards, JSON-Path, for all our referencing, as it is fairly intuitive and well-documented.

Below you can find a variety of referencing examples to get you started. For any questions, please reach out to support.

Accessing list data in a nested dictionary

How to access data - below is the result of the connector with the ref hubs1:

{
  "deals": [
    {
      "portalId": 123213213,
      "dealId": 345345345,
      "isDeleted": false,
      "associations": null,
      "properties": ...

To access the dealId in the next step, you need to write the following in the respective field where you want the data to be: {{ hubs1.deals.0.dealId }}

Explanation:

  • All data referencing is based on Jinja2, the Python templating language. It is similar to Liquid or other templating languages, with some nuances.

  • The {{ }} is always used when data is referenced to from a previous step.

  • The hubs1 references the previous flow run step itself by its RefID

  • The deals references the object in the above JSON

  • Since within the "deals": [ a list is nested, indicated by the [ order, we need to specify that we want to access the first object of the list, while the first one is in any programming-related terms 0.

  • Lastly, we concatenate with periods a period the dealId. Note that the letter I in dealId is capitalized (Camel case style) in this particular API from Hubspot. This is important, as APIs are case-sensitive.

When working with dictionaries in Python, example.items to access a key named items because items() is a built-in method of dictionaries. Instead, use the bracket notation like example['items'].

Example:

Given that the previous step returns a dictionary like this, and you want to reference items in it:

{
    "items": [
        {
            "id": 234,
            "position": 10,
            "roomCount": null,
            "entranced": ...

To access the items list, use: get_units['items']

DO NOT useget_units.items, as this will result in an error.

Last updated