Add force property override feature to patcher

This has a variety of applications, but is particularly useful when we want to replace arrays instead of add onto them
This commit is contained in:
gsemaj 2021-05-02 00:14:35 -04:00 committed by Gent Semaj
parent af8dd61967
commit 36cb32454d

View File

@ -961,6 +961,15 @@ static void patchJSON(json* base, json* patch) {
std::string key = _prop.key(); // static identifier
json* valLoc = &(*_prop); // pointer to json data
// special casing for forced replacement.
// the ! is stripped, then the property is forcibly replaced without a recursive call
// that means no type checking, so use at your own risk
if (key.c_str()[0] == '!') {
key = key.substr(1, key.length() - 1);
(*base)[key] = *valLoc;
continue;
}
// search for matching property in base object
json::iterator _match = base->find(key);
if (_match != base->end()) {