We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I have JSON config in Json::Value json_config of following format:
{ "configuration":{ "services":{ "analytics":{ "export-profile":[ { "name":"export_1000", "transport":"grpc" } ], "sensor":[ { "name":"sensor_1000", "export-name":"export_1000", } ] } } } }
How can I merge multiple similar above mentioned Json::Value such as below
{ "configuration":{ "services":{ "analytics":{ "export-profile":[ { "name":"export_1001", "transport":"grpc" } ], "sensor":[ { "name":"sensor_1001", "export-name":"export_1001", } ] } } } }
into one so that the final config looks something like below:
{ "configuration":{ "services":{ "analytics":{ "export-profile":[ { "name":"export_1000", "transport":"grpc" }, { "name":"export_1001", "transport":"grpc" }, ... ], "sensor":[ { "name":"sensor_1000", "export-name":"export_1000", }, { "name":"sensor_1001", "export-name":"export_1001", }, ... ] } } } }
I tried below, but it ends up replacing the previous config, and at the end only the last one remains.
void merge_json_objs (Json::Value& super, Json::Value& sub) { // Merge all members of sub into super for (const auto& key : sub.getMemberNames()) { if (super[key].type() == Json::objectValue && sub[key].type() == Json::objectValue) { merge_json_objects(super[key], sub[key]); } else { super[key] = sub[key]; } } }
OS: FreeBSD11, compiler: gcc 4.2 JsonCpp version: 1.7.4
The text was updated successfully, but these errors were encountered:
This is the wrong repository - this is "JSON for Modern C++", not JsonCpp.
Sorry, something went wrong.
No branches or pull requests
I have JSON config in Json::Value json_config of following format:
How can I merge multiple similar above mentioned Json::Value such as below
into one so that the final config looks something like below:
I tried below, but it ends up replacing the previous config, and at the end only the last one remains.
OS: FreeBSD11,
compiler: gcc 4.2
JsonCpp version: 1.7.4
The text was updated successfully, but these errors were encountered: