The macro ARDUINOJSON_ENABLE_NAN activates the support of NaN in JSON input and output documents.

If ARDUINOJSON_ENABLE_NAN is set to 0 (the default):

If ARDUINOJSON_ENABLE_NAN is set to 1:

The default value (ARDUINOJSON_ENABLE_NAN == 0) is more portable, because it matches the behavior of most JSON libraries. Indeed, the JSON specification doesn’t allow NaN, so very few JSON libraries support it.

History

ArduinoJson 6.11.0 added this option, as well as ARDUINOJSON_ENABLE_INFINITY. Previously, NaN was always supported, as if ARDUINOJSON_ENABLE_NAN was 1.

How to force the value?

If you need to support NaN in your program, define ARDUINOJSON_ENABLE_NAN to 1 before including ArduinoJson.h:

#define ARDUINOJSON_ENABLE_NAN 1
#include <ArduinoJson.h>

See also