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

#define ARDUINOJSON_VERSION "6.0.1-beta"
#define ARDUINOJSON_VERSION_MAJOR 6
#define ARDUINOJSON_VERSION_MINOR 0
#define ARDUINOJSON_VERSION_REVISION 1

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!=6 || ARDUINOJSON_VERSION_MINOR<1
#error ArduinoJson 6.1+ 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

Global warming stripes by Professor Ed Hawkins (University of Reading)