How to merge keys and values from two objects into one object?

Hi there! I need to merge two objects so that the resulting object contains all the keys and values from both.

For example:

// Object 1
{
“a”: 1,
“b”: 2
}

// Object 2
{
“c”: 3,
“d”: 4
}

// Desired result
{
“a”: 1,
“b”: 2,
“c”: 3,
“d”: 4
}

Anyone have any efficient way to do this?

Hi @Endre_F_M, I’ve tried merging objects, but in vain. I managed to merge keys a b c d to generate a new merged bundle though, using array aggregator :

json merge.json (6.6 KB)

update : merging bundles don’t really work with array aggregator though.

Thank you very much for your effor and try, @kudracha ! I will keep on trying until some of us find a smooth solution hopefully :slight_smile:

Hi @Endre_F_M, If your bundle1 and bundle2 have some expected structure (and the output, ideally), my previous solution of array aggregator would work. If you’re interested in more flexible solution, it’d be this one :

I basically convert bundle1 and bundle2 into json strings and remove } { finishing and starting brackets for bundle1 and bundle2 respectively and instead replace it with a comma. Then parse whole merge json string into an object.

json merge 2.json (9.8 KB)