Merge

Merges two or more objects into a single object.

Syntax

json_object merge(args[]:json_object $objects)

Parameters

$objects: A variable number of objects that should be merged together.

Note that the merge function will gather the objects in a chain (concatenate). If the same key is mentioned more than once, the value of the last object will be outputted as the logic of replacement works in order of arguments provided.

Example

{
    "UserInfomation": {
        "FirstName": "John",
        "LastName": "Doe",

    },
    "AccessLevel": {
        "Enabled": false,
        "Role": [
            "User"
        ]
    },
    "NewAccessLevel": {
        "Enabled": true,
        "Role": [
            "Admin"
        ]
    }
}
merge(@.UserInfomation, @.AccessLevel, @.NewAccessLevel)
{
    "FirstName": "John",
    "LastName": "Doe",
    "Enabled": true,
    "Role": [
        "User",
        "Admin"
    ]
}