jquery – a way to combine/merge objects in json

I have this inconvenient output of data, like this:

[
    {
        "object_a": {
            "1": "some value of 1",
            "2": "some value of 2",
            "3": ""
        },
        "obejct_b": {
            "1": "",
            "2": "",
            "3": "some value of 3"
        },
        ..some other objects..
    }
    {
        "object_a": {
            "1": "some value of 1",
            "2": "",
            "3": "some value of 3"
    },
        "obejct_b": {
            "1": "",
            "2": "some value of 2",
            "3": ""
        },
        ..some other objects..
    }
    {
        "object_a": {
            "1": "",
            "2": "some value of 2",
            "3": ""
        },
        "obejct_b": {
            "3": "some value of 3",
            "1": "some value of 1",
            "2": ""
        },
        ..some other objects..
    }
]

I don’t know what more to add. It looks straightforward as it is.
Unfortunately, I cannot change the output format.
The problem is that some data is in “object_a” and some in “object_b”

The desired output would be like:

[
    {
        "object": {
            "1": "some value of 1",
            "2": "some value of 2",
            "3": "some value of 3"
        }
        ..some other objects..
    }
    {
        "object": {
            "1": "some value of 1",
            "2": "some value of 2",
            "3": "some value of 3"
        },
        ..some other objects..
    }
        {
        "object": {
            "2": "some value of 2",
            "3": "some value of 3",
            "1": "some value of 1",
        },
        ..some other objects..
    }
]

I couldn’t find a way to combine/merge two objects together, with jQuery.

Thanks.

Read more here: Source link