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

Function FindJSON

test/src/utils/Baseline.cpp:72–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72static 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
93static std::string GetJSONValue(nlohmann::json& target, const std::string& key) {
94 std::lock_guard<std::mutex> autoLock(jsonLocker);

Callers 2

GetJSONValueFunction · 0.85
SetJSONValueFunction · 0.85

Calls 1

findMethod · 0.45

Tested by

no test coverage detected