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 7.0.0-beta defines the following:

#define ARDUINOJSON_VERSION "7.0.0-beta"
#define ARDUINOJSON_VERSION_MAJOR 7
#define ARDUINOJSON_VERSION_MINOR 0
#define ARDUINOJSON_VERSION_REVISION 0

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 != 7
#error ArduinoJson 7 is required
#endif

How to display ArduinoJson version?

Serial.print("Using ArduinoJson version ");
Serial.println(ARDUINOJSON_VERSION);
Global warming stripes by Professor Ed Hawkins (University of Reading)