Skip to content

Commit c498f8f

Browse files
committed
simpler. no string copies, no JsonObject required
1 parent eb7799d commit c498f8f

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/UniversalTelegramBot.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,15 +331,12 @@ bool UniversalTelegramBot::getMe() {
331331
String response = sendGetToTelegram(command); // receive reply from telegram.org
332332
DynamicJsonDocument doc(maxMessageLength);
333333
DeserializationError error = deserializeJson(doc, response);
334-
JsonObject obj = doc.as<JsonObject>(); //there is nothing better right now to use obj.containsKey("result")
335334
closeClient();
336335

337336
if (!error) {
338-
if (obj.containsKey("result")) {
339-
String _name = doc["result"]["first_name"];
340-
String _username = doc["result"]["username"];
341-
name = _name;
342-
userName = _username;
337+
if (doc.containsKey("result")) {
338+
name = doc["result"]["first_name"].as<String>();
339+
userName = doc["result"]["username"].as<String>();
343340
return true;
344341
}
345342
}

0 commit comments

Comments
 (0)