MCPcopy Create free account
hub / github.com/Tencent/libpag / FindJSON

Function FindJSON

test/src/utils/Baseline.cpp:264–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262}
263
264static nlohmann::json* FindJSON(nlohmann::json& md5JSON, const std::string& key,
265 std::string* lastKey) {
266 std::vector<std::string> keys = {};
267 size_t start;
268 size_t end = 0;
269 while ((start = key.find_first_not_of('/', end)) != std::string::npos) {
270 end = key.find('/', start);
271 keys.push_back(key.substr(start, end - start));
272 }
273 *lastKey = keys.back();
274 keys.pop_back();
275 auto json = &md5JSON;
276 for (auto& jsonKey : keys) {
277 if ((*json)[jsonKey] == nullptr) {
278 (*json)[jsonKey] = {};
279 }
280 json = &(*json)[jsonKey];
281 }
282 return json;
283}
284
285std::string Baseline::getJSONValue(nlohmann::json& target, const std::string& key) {
286 std::lock_guard<std::mutex> autoLock(locker);

Callers 2

getJSONValueMethod · 0.85
setJSONValueMethod · 0.85

Calls 2

findMethod · 0.80
push_backMethod · 0.80

Tested by

no test coverage detected