Create an object of objects with merge I'm trying to create an object of objects, can anyone suggest why object would only contain the last iteration of "itemObject"?

{% set object = {} %}

{% for entry in craft.entries.section("mainSectionsStructure") %}
    {% set itemObject = {
            "title": entry.title,
            "link": entry.url
        } %}

    {% set object = object|merge(itemObject) %}

{% endfor %}

{{ object|json_encode() }}
You're overriding the "title" and "link" properties on every iteration. Wrap the itemObject object in [] to merge the whole object into your array.

{% set object = object|merge([itemObject]) %}