MCPcopy Create free account
hub / github.com/TelegramMessenger/cocoon / get_json_value

Method get_json_value

runners/helpers/CountTokens.cpp:27–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25 }
26
27 static td::int64 get_json_value(nlohmann::json &json, const std::vector<std::string> &sub) {
28 auto *ptr = &json;
29 for (const auto &f : sub) {
30 if (!ptr->is_object()) {
31 return 0;
32 }
33 if (!ptr->contains(f)) {
34 return 0;
35 }
36 ptr = &(*ptr)[f];
37 }
38 if (!ptr->is_number_unsigned()) {
39 return 0;
40 }
41 return ptr->get<td::int64>();
42 }
43
44 std::string add_next_answer_slice(td::Slice event) override {
45 last_ += event.str();

Callers

nothing calls this directly

Calls 1

is_objectMethod · 0.45

Tested by

no test coverage detected