CAUTION: SLIPPERY FLOORThe Arduino Library Manager installs the ArduinoJson version 6 by default.
However, using version 5 is highly recommended because version 6 is still in beta stage.
Open the Arduino Library Manager and make sure that ArduinoJson version 5 is installed.
ArduinoJson defines several macros to allow a program to detect the version of the library.
There are four macros:
ARDUINOJSON_VERSIONis a string that is typically used to display the version to the user
ARDUINOJSON_VERSION_MAJORcontains the major version number
ARDUINOJSON_VERSION_MINORcontains the minor version number
ARDUINOJSON_VERSION_REVISIONcontains the revision number
For example, ArduinoJson 5.13.2 defines the following:
#define ARDUINOJSON_VERSION "5.13.2" #define ARDUINOJSON_VERSION_MAJOR 5 #define ARDUINOJSON_VERSION_MINOR 13 #define ARDUINOJSON_VERSION_REVISION 2
How to use?
How to detect that ArduinoJson is available?
#ifndef ARDUINOJSON_VERSION #error ArduinoJson not found, please include ArduinoJson.h in your .ino file #endif
How to verify that the right version is installed?
#if ARDUINOJSON_VERSION_MAJOR!=5 || ARDUINOJSON_VERSION_MINOR<13 #error ArduinoJson 5.13+ is required #endif
How to display ArduinoJson version?
Serial.print("Using ArduinoJson version "); Serial.println(ARDUINOJSON_VERSION);
These macros are available since ArduinoJson 5.13.2