Issue with Arduino library - cannot compile the code with new Arduino JSON library (>6.X)

Hi there.
I am reporting an issue with Arduino IDE, when trying to compile an example code for ESP8266.
My IDE version is 1.8.9 (Windows Store 1.9.21.0) with Losant library 1.3.0, Arduino JSON by Benoit Blanchon ver 6.12.0.

When compiling an example, following errors are showing:
"Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: “NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled, All SSL ciphers (most compatible), 4M (no SPIFFS), v2 Higher Bandwidth, Disabled, None, Only Sketch, 115200”

C:\xxx\Arduino\libraries\losant-mqtt-arduino-master\src\internal\LosantDevice.cpp:8:11: error: DynamicJsonBuffer is a class from ArduinoJson 5. Please see arduinojson.org/upgrade to learn how to upgrade your program to ArduinoJson version 6

DynamicJsonBuffer jsonBuffer;

       ^

C:\xxx\Arduino\libraries\losant-mqtt-arduino-master\src\internal\LosantDevice.cpp:90:11: error: StaticJsonBuffer is a class from ArduinoJson 5. Please see arduinojson.org/upgrade to learn how to upgrade your program to ArduinoJson version 6

StaticJsonBuffer<100> jsonBuffer;

       ^

C:\xxx\Arduino\libraries\losant-mqtt-arduino-master\src\internal\LosantDevice.cpp: In function ‘void commandReceived(char*, byte*, unsigned int)’:

C:\xxx\Arduino\libraries\losant-mqtt-arduino-master\src\internal\LosantDevice.cpp:8:21: error: ‘jsonBuffer’ was not declared in this scope

DynamicJsonBuffer jsonBuffer;

                 ^

C:\xxx\Arduino\libraries\losant-mqtt-arduino-master\src\internal\LosantDevice.cpp:11:11: error: ‘ArduinoJson::JsonObject’ has no member named ‘success’

if(root.success()) {

       ^

C:\xxx\Arduino\libraries\losant-mqtt-arduino-master\src\internal\LosantDevice.cpp:14:41: error: ‘ArduinoJson6120_000001::enable_if<true, ArduinoJson6120_000001::MemberProxy<const ArduinoJson6120_000001::ObjectRef&, const char*> >::type’ has no member named ‘asObject’

 command.payload = &(root["payload"].asObject());

                                     ^

C:\xxx\Arduino\libraries\losant-mqtt-arduino-master\src\internal\LosantDevice.cpp: In member function ‘void LosantDevice::sendState(ArduinoJson::JsonObject&)’:

C:\xxx\Arduino\libraries\losant-mqtt-arduino-master\src\internal\LosantDevice.cpp:90:19: error: expected primary-expression before ‘<’ token

StaticJsonBuffer<100> jsonBuffer;

               ^

C:\xxx\Arduino\libraries\losant-mqtt-arduino-master\src\internal\LosantDevice.cpp:90:25: error: ‘jsonBuffer’ was not declared in this scope

StaticJsonBuffer<100> jsonBuffer;

                     ^

C:\xxx\Arduino\libraries\losant-mqtt-arduino-master\src\internal\LosantDevice.cpp:96:8: error: ‘ArduinoJson::JsonObject’ has no member named ‘printTo’

root.printTo(stateStr);

    ^

exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.
"

Hi @Marcin_Wojcik,

Thank you for this bug report! We do have an open ticket for this issue, and I will update you when a fix is implemented.

Thanks,
Julia

is there any update? Last time losant-mqtt-arduino library was updated 4 years ago, also PubSubClient is a bit outdated with 128 size limit

Hi @Denis_Leskovar,

This has not been updated since the last request, but I will keep you updated on the status of this ticket. The last update to the losant-mqtt-arduino library was in September of 2018. The PubSubClient library was last updated November of 2019, and features a configurable MQTT_MAX_PACKAGE_SIZE, which defaults to 128 bytes.

I will comment on this post should anything change or be updated in the near future. :smile:

Thanks!
Julia

Thank you - I will test new PubSubClient library then. Please consider update of losant-mqtt, I am still awaiting good news in this topic :slight_smile: