Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge two json objects #1807

Closed
georgii-ivanov opened this issue Oct 23, 2019 · 2 comments
Closed

Merge two json objects #1807

georgii-ivanov opened this issue Oct 23, 2019 · 2 comments
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@georgii-ivanov
Copy link

OS: ubuntu x64, compiler is g++

I'd like to merge two objects:

json obj1 = {
   { "a": 1 }
}

json obj2 = {
   { "b": 2 }
}

Expected result:

 {
   { "a": 1 },
   { "b": 2 }
}

I found in example that I could be done with merge_patch method but I can't find it in my installed package.
I've installed the library from ubuntu package: https://packages.ubuntu.com/bionic/nlohmann-json-dev

error: ‘using json = using json = class nlohmann::basic_json<> {aka class nlohmann::basic_json<>}’ has no member named ‘merge_patch’
obj1.merge_patch(obj2);

@nlohmann
Copy link
Owner

Try obj1.update(obj2).

@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Oct 23, 2019
@georgii-ivanov
Copy link
Author

I updated the package. Now I use merge_patch. Works as charm! Thank you @nlohmann

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants