1. Home
  2. Workflows
  3. Accessing Values Inside JSON Arrays

Accessing Values Inside JSON Arrays

While working with APIs and JSON resources, you’ll often get the data in an array, rather than a single value. An array is simply a list of items, where each item can have multiple properties, such as an ID or a name.

{
    "outer": [
        {
            "id": 0,
            "name": "First object"
        },
        {
            "id": 1,
            "name": "Second object"
        },
        {
            "id": 2,
            "name": "Third object"
        }
    ]
}

To access the name of the first object in the array above, you can use the following expression:

{{my_json_resource.outer[0].name}}

This would retrieve the name value (“First object“) from the first item in the array “outer” found in the JSON resource my_json_resource.

However, sometimes this is not enough. We may not know the order in which the items will appear in the array. But what if you know the value of one key and want to infer the value of another from it? For example, take a look at the array below.

{
  "firstname": "John",
  "lastname": "Doe",
  "phonenumbers": [
    {
      "number": "+46700000001",
      "type": "work"
    },
    {
      "number": "+46700000002",
      "type": "other"
    },
    {
      "number": "+46700000003",
      "type": "mobile"
    }
  ]
}

Say we have saved this in a JSON resource called “customer” and want to retrieve the number with the type “mobile“.

You need to address the JSON resource, look inside the array, find the item you want, and return a specific value from it. This is done by using a more advanced expression.

The example below demonstrates how to select one item from an array based on a condition and then retrieve a specific property from that item.

{{customer.phonenumbers[?(@.type == 'mobile')].number}}

You can read this expression like this:

  • customer
    The JSON resource “customer” containing JSON data.
  • .phonenumbers
    Accesses the phonenumbers array in the JSON resource.
  • [?(@.type == 'mobile')]
    A filter expression: it iterates the phonenumbers array and selects only elements where the property type equals “mobile“. The @ refers to the current element being evaluated.
  • .number
    Once the filtering is applied, this retrieves the “number” property of the matched element.

In this example, the resulting string is “46700000003”.

This expression is helpful when you receive JSON with arrays (e.g., a list of items from an API) and need to extract specific data before storing it in metadata, or if you want to simplify downstream logic by extracting only the field you need without separate parsing or condition jobs.

Note that this expression will only work if it results in one matching element. Matching multiple items will simply return the expression (“customer.phonenumbers[?(@.type == ‘mobile’)].number“) and will need to be handled elsewhere (e.g., in a subsequent route from metadata job or similar).

Updated on 2026-01-05

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Contact Support