Skip to content

Merge two json objects #1807

Closed
Closed
@georgii-ivanov

Description

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);

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions