{"id":4258,"date":"2022-12-15T12:22:25","date_gmt":"2022-12-15T12:22:25","guid":{"rendered":"https:\/\/info.documotor.com\/?page_id=4258"},"modified":"2023-01-25T10:20:10","modified_gmt":"2023-01-25T10:20:10","slug":"merge","status":"publish","type":"page","link":"https:\/\/info.documotor.com\/?page_id=4258","title":{"rendered":"Merge"},"content":{"rendered":"\n<p id=\"block-1723625f-fbf3-4ecc-9b1a-a1a407ef1eb4\">Merges two or more objects into a single object. <\/p>\n\n\n\n<h3>Syntax<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">json_object merge(args[]:json_object $objects)<\/code><\/pre>\n\n\n\n<h3 id=\"block-10dece16-400f-4ff3-9440-e9f3f11f15e3\">Parameters<\/h3>\n\n\n\n<p><strong>$objects:<\/strong> A variable number of objects that should be merged together. <\/p>\n\n\n\n<p>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. <\/p>\n\n\n\n<h3 id=\"block-36dae574-80c9-4310-9d54-3e95620c8263\">Example<\/h3>\n\n\n\n<pre title=\"Data\" class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">{\n    \"UserInfomation\": {\n        \"FirstName\": \"John\",\n        \"LastName\": \"Doe\",\n\n    },\n    \"AccessLevel\": {\n        \"Enabled\": false,\n        \"Role\": [\n            \"User\"\n        ]\n    },\n    \"NewAccessLevel\": {\n        \"Enabled\": true,\n        \"Role\": [\n            \"Admin\"\n        ]\n    }\n}<\/code><\/pre>\n\n\n\n<pre title=\"Transformation\" class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">merge(@.UserInfomation, @.AccessLevel, @.NewAccessLevel)<\/code><\/pre>\n\n\n\n<pre title=\"Output\" class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">{\n    \"FirstName\": \"John\",\n    \"LastName\": \"Doe\",\n    \"Enabled\": true,\n    \"Role\": [\n        \"User\",\n        \"Admin\"\n    ]\n}<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p id=\"block-d91f7780-9dbd-4101-9b89-3a9c9219c612\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Merges two or more objects into a single object. Syntax 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 [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"parent":271,"menu_order":120,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/4258"}],"collection":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/info.documotor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4258"}],"version-history":[{"count":8,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/4258\/revisions"}],"predecessor-version":[{"id":4756,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/4258\/revisions\/4756"}],"up":[{"embeddable":true,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/271"}],"wp:attachment":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}