The macro ARDUINOJSON_ENABLE_STD_STRING enables the support of the type std::string in the library.

If ARDUINOJSON_ENABLE_STD_STRING is defined 1, then std::string is supported.

Default value

ArduinoJson tries to guess whether std::string is available or not, based on the presence of the ARDUINO macro.

The default value of ARDUINOJSON_ENABLE_STD_STRING is:

  • 0 if ARDUINO is defined,
  • 1 otherwise.

In other words, std::string is supported as soon as you work outside of Arduino.

How to force support for std::string?

If you need to force the support of std::string, add the following line at the top of your program:

#define ARDUINOJSON_ENABLE_STD_STRING 1
#include <ArduinoJson.h>

How to disable support for std::string

If for some reason, you need to disable the support for std::string, add the following line at the top of your program:

#define ARDUINOJSON_ENABLE_STD_STRING 0
#include <ArduinoJson.h>

See also