ARDUINOJSON_ENABLE_INFINITY
Description
The macro ARDUINOJSON_ENABLE_INFINITY activates the support of Infinity in JSON input and output documents.
If ARDUINOJSON_ENABLE_INFINITY is set to 0 (the default):
deserializeJson()returns InvalidInput when the input containsInfinity,serializeJson()producesnullwhen theJsonDocumentcontainsInfinity.
If ARDUINOJSON_ENABLE_INFINITY is set to 1:
deserializeJson()storesInfinityin theJsonDocumentwhen the input containsInfinity,serializeJson()producesInfinitywhen theJsonDocumentcontainsInfinity.
The default value (ARDUINOJSON_ENABLE_INFINITY == 0) is more portable, because it matches the behavior of most JSON libraries. Indeed, the JSON specification doesn’t allow Infinity, so very few JSON libraries support it.
Only 0 and 1 are valid. Any other value (like false or true) will produce a compilation error.
ARDUINOJSON_ENABLE_INFINITY as added in ArduinoJson 6.11; previously, Infinity was always supported.
How to force the value?
If you need to support Infinity in your program, define ARDUINOJSON_ENABLE_INFINITY to 1 before including ArduinoJson.h:
#define ARDUINOJSON_ENABLE_INFINITY 1
#include <ArduinoJson.h>
Several
.inoor.cppfiles?Be careful if several compilation units compose your program, i.e., if your project contains several
.inoor.cppfiles.You should define the same value of
ARDUINOJSON_ENABLE_INFINITYin each compilation unit; otherwise, the executable will be much bigger because it will contain two variants of the library.