Description

ArduinoJson defines several macros to allow a program to detect the version of the library.

There are four macros:

  • ARDUINOJSON_VERSION is a string that is typically used to display the version to the user
  • ARDUINOJSON_VERSION_MAJOR contains the major version number
  • ARDUINOJSON_VERSION_MINOR contains the minor version number
  • ARDUINOJSON_VERSION_REVISION contains 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);

Availability

These macros are available since ArduinoJson 5.13.2