Skip to content

Bump ArduinoJson to 7.x.x #358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void handleNewMessages(int numNewMessages)

if (bot.checkForOkResponse(response))
{
DynamicJsonDocument images(1500);
JsonDocument images;
DeserializationError error = deserializeJson(images, response);

// There are 3 image sizes after Telegram has process photo
Expand Down
2 changes: 1 addition & 1 deletion examples/ESP8266/BulkMessages/BulkMessages.ino
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const unsigned long BOT_MTBS = 1000; // Mean time b
WiFiClientSecure secured_client;
X509List cert(TELEGRAM_CERTIFICATE_ROOT);
UniversalTelegramBot bot(BOT_TOKEN, secured_client);
DynamicJsonDocument usersDoc(1500);
JsonDocument usersDoc;
unsigned long bot_lasttime; // last time messages' scan has been done

JsonObject getSubscribedUsers()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void handleNewMessages(int numNewMessages)

if (bot.checkForOkResponse(response))
{
DynamicJsonDocument images(1500);
JsonDocument images;
DeserializationError error = deserializeJson(images, response);

// There are 3 image sizes after Telegram has process photo
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"platforms": "*",
"dependencies": [
{
"name": "bblanchon/ArduinoJson"
"bblanchon/ArduinoJson": "^7.0.0"
}
],
"build": {
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ default_envs = d1_mini

[env]
lib_deps =
ArduinoJson
bblanchon/ArduinoJson@^7.0.0
monitor_speed = 115200

[env:d1_mini]
Expand Down
26 changes: 13 additions & 13 deletions src/UniversalTelegramBot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ String UniversalTelegramBot::sendMultipartFormDataToTelegram(

bool UniversalTelegramBot::getMe() {
String response = sendGetToTelegram(BOT_CMD("getMe")); // receive reply from telegram.org
DynamicJsonDocument doc(maxMessageLength);
JsonDocument doc;
DeserializationError error = deserializeJson(doc, ZERO_COPY(response));
closeClient();

Expand All @@ -324,7 +324,7 @@ bool UniversalTelegramBot::getMe() {
* Returns true, if the command list was updated successfully *
********************************************************************************/
bool UniversalTelegramBot::setMyCommands(const String& commandArray) {
DynamicJsonDocument payload(maxMessageLength);
JsonDocument payload;
payload["commands"] = serialized(commandArray);
bool sent = false;
String response = "";
Expand Down Expand Up @@ -383,7 +383,7 @@ int UniversalTelegramBot::getUpdates(long offset) {
#endif

// Parse response into Json object
DynamicJsonDocument doc(maxMessageLength);
JsonDocument doc;
DeserializationError error = deserializeJson(doc, ZERO_COPY(response));

if (!error) {
Expand Down Expand Up @@ -562,7 +562,7 @@ bool UniversalTelegramBot::sendSimpleMessage(const String& chat_id, const String
bool UniversalTelegramBot::sendMessage(const String& chat_id, const String& text,
const String& parse_mode, int message_id) { // added message_id

DynamicJsonDocument payload(maxMessageLength);
JsonDocument payload;
payload["chat_id"] = chat_id;
payload["text"] = text;

Expand All @@ -579,14 +579,14 @@ bool UniversalTelegramBot::sendMessageWithReplyKeyboard(
const String& chat_id, const String& text, const String& parse_mode, const String& keyboard,
bool resize, bool oneTime, bool selective) {

DynamicJsonDocument payload(maxMessageLength);
JsonDocument payload;
payload["chat_id"] = chat_id;
payload["text"] = text;

if (parse_mode != "")
payload["parse_mode"] = parse_mode;

JsonObject replyMarkup = payload.createNestedObject("reply_markup");
JsonObject replyMarkup = payload["reply_markup"].to<JsonObject>();

replyMarkup["keyboard"] = serialized(keyboard);

Expand All @@ -610,7 +610,7 @@ bool UniversalTelegramBot::sendMessageWithInlineKeyboard(const String& chat_id,
const String& keyboard,
int message_id) { // added message_id

DynamicJsonDocument payload(maxMessageLength);
JsonDocument payload;
payload["chat_id"] = chat_id;
payload["text"] = text;

Expand All @@ -620,7 +620,7 @@ bool UniversalTelegramBot::sendMessageWithInlineKeyboard(const String& chat_id,
if (parse_mode != "")
payload["parse_mode"] = parse_mode;

JsonObject replyMarkup = payload.createNestedObject("reply_markup");
JsonObject replyMarkup = payload["reply_markup"].to<JsonObject>();
replyMarkup["inline_keyboard"] = serialized(keyboard);
return sendPostMessage(payload.as<JsonObject>(), message_id); // if message id == 0 then edit is false, else edit is true
}
Expand Down Expand Up @@ -705,7 +705,7 @@ String UniversalTelegramBot::sendPhoto(const String& chat_id, const String& phot
int reply_to_message_id,
const String& keyboard) {

DynamicJsonDocument payload(maxMessageLength);
JsonDocument payload;
payload["chat_id"] = chat_id;
payload["photo"] = photo;

Expand All @@ -719,7 +719,7 @@ String UniversalTelegramBot::sendPhoto(const String& chat_id, const String& phot
payload["reply_to_message_id"] = reply_to_message_id;

if (keyboard.length() > 0) {
JsonObject replyMarkup = payload.createNestedObject("reply_markup");
JsonObject replyMarkup = payload["reply_markup"].to<JsonObject>();
replyMarkup["keyboard"] = serialized(keyboard);
}

Expand All @@ -728,7 +728,7 @@ String UniversalTelegramBot::sendPhoto(const String& chat_id, const String& phot

bool UniversalTelegramBot::checkForOkResponse(const String& response) {
int last_id;
DynamicJsonDocument doc(response.length());
JsonDocument doc;
deserializeJson(doc, response);

// Save last sent message_id
Expand Down Expand Up @@ -783,7 +783,7 @@ bool UniversalTelegramBot::getFile(String& file_path, long& file_size, const Str
String command = BOT_CMD("getFile?file_id=");
command += file_id;
String response = sendGetToTelegram(command); // receive reply from telegram.org
DynamicJsonDocument doc(maxMessageLength);
JsonDocument doc;
DeserializationError error = deserializeJson(doc, ZERO_COPY(response));
closeClient();

Expand All @@ -799,7 +799,7 @@ bool UniversalTelegramBot::getFile(String& file_path, long& file_size, const Str
}

bool UniversalTelegramBot::answerCallbackQuery(const String &query_id, const String &text, bool show_alert, const String &url, int cache_time) {
DynamicJsonDocument payload(maxMessageLength);
JsonDocument payload;

payload["callback_query_id"] = query_id;
payload["show_alert"] = show_alert;
Expand Down