Retrieving Values From Nested Collections

I have an array like:

{
    "meta_data": [
        {
            "item": 1
        },
        {
            "item": 2
        },
        {
            "item": 3
        },
        {
            "id": 35781,
            "key": "_gravity_forms_history",
            "value": {
                "_gravity_form_cart_item_key": "abc",
                "_gravity_form_linked_entry_id": 123,
                "_gravity_form_lead": {
                    "40": "",
                    "117": "0",
                    "form_id": "46"
                }
            }
        }
    ]
}

And I need to get the value for the form_id.

I’ve got as far as extracting the _gravity_forms_history with {{first(map(5.meta_data; "value"; "key"; "_gravity_forms_history"))}} but now I’m not sure how to access the contents of the nested collections?

I know I can turn each nested collection into an array and then map the contents, like this -

{{first(map(toArray(first(map(toArray(first(map(5.meta_data; "value"; "key"; "_gravity_forms_history"))); "value"; "key"; "_gravity_form_lead"))); "value"; "key"; "form_id"))}}

But it seems like there should be a more straightforward alternative, like using dot notation?

Hi @alexs Yes, dot notation would work.
{{get(map(5.meta_data; “value._gravity_form_lead.form_id”); 4)}}

Hope that helps :slight_smile:

4 Likes