| 70 | } |
| 71 | |
| 72 | static nlohmann::json* FindJSON(nlohmann::json& md5JSON, const std::string& key, |
| 73 | std::string* lastKey) { |
| 74 | std::vector<std::string> keys = {}; |
| 75 | size_t start; |
| 76 | size_t end = 0; |
| 77 | while ((start = key.find_first_not_of('/', end)) != std::string::npos) { |
| 78 | end = key.find('/', start); |
| 79 | keys.push_back(key.substr(start, end - start)); |
| 80 | } |
| 81 | *lastKey = keys.back(); |
| 82 | keys.pop_back(); |
| 83 | auto json = &md5JSON; |
| 84 | for (auto& jsonKey : keys) { |
| 85 | if ((*json)[jsonKey] == nullptr) { |
| 86 | (*json)[jsonKey] = {}; |
| 87 | } |
| 88 | json = &(*json)[jsonKey]; |
| 89 | } |
| 90 | return json; |
| 91 | } |
| 92 | |
| 93 | static std::string GetJSONValue(nlohmann::json& target, const std::string& key) { |
| 94 | std::lock_guard<std::mutex> autoLock(jsonLocker); |
no test coverage detected