You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{ "object",{ "currency", "USD" },{ "value", 42.99 }} is giving you an array of objects indexed by the key object. Hence when you merge-patch it with another array: { "currency", "EUR" } it gets replaced.
There is no bug here, you need an extra {} around the elements for object to get nested objects.
You can easily see it in your output: the brackets [] around "currency" and "EUR" are indication an array not an object.
So just to sum things up: If you want to merge two objects, keep in account that everything that is constructed as an array will be replaced when setting a different array.
To make things work if you don't want this: change your array to std::map.
I have two objects which I want to merge using the
merge_patch()
function. An example of my objects:When merging B into A, the library seems to delete value A{c[{b}]}.
Please describe the steps to reproduce the issue. Can you provide a small but working code example?
What is the expected behavior?
I was expecting for all the original values to remain because they are not defined in the patch object
And what is the actual behavior instead?
The original values that are not defined are removed
Which compiler and operating system are you using? Is it a supported compiler?
Did you use a released version of the library or the version from the
develop
branch?latest version
If you experience a compilation error: can you compile and run the unit tests?
The text was updated successfully, but these errors were encountered: