json_merge_preserve(JsonDocument, Patch)

The json_merge_preserve function provides a way to patch a target JSON document with another JSON document while preserving the content that exists in the target document.

Keys in JsonDocument are merged if found in Patch. If the same key exists in both the target and patch file the result will be an array with the values from both target and patch.

If the value in Patch is null then the key will be removed in the target document.

json_merge_preserve('{"a":"b"}',          '{"a":"c"}'

json_merge_preserve('{"a": [{"b":"c"}]}', '{"a": [1]}'

json_merge_preserve('[1,2]',              '{"a":"b", "c":null}'

Copyright © Thunderstone Software     Last updated: Apr 15 2024
Copyright © 2024 Thunderstone Software LLC. All rights reserved.