ArduinoJson 7 uses integers instead of pointers to locate the nodes in the JsonDocument. ARDUINOJSON_SLOT_ID_SIZE sets the number of bytes used by this integer, called “slot id”.

The size of slot id depends on the CPU architecture.

CPU architecture Slot id size Max nodes
8-bit 1 255
32-bit 2 65,635
64-bit 4 4,294,967,294

You can override the default value by defining ARDUINOJSON_SLOT_ID_SIZE before including ArduinoJson’s headers.

For example, you can set ARDUINOJSON_SLOT_ID_SIZE if you need to store more than 65,635 nodes in a JsonDocument:

#define ARDUINOJSON_SLOT_ID_SIZE 4
#include <ArduinoJson.h>

You can simulate the effect of changing ARDUINOJSON_SLOT_ID_SIZE with the ArduinoJson Assistant.

Several .ino or .cpp files?

Be careful if several compilation units compose your program, i.e., if your project contains several .ino or .cpp files.

You should define the same value of ARDUINOJSON_SLOT_ID_SIZE in each compilation unit; otherwise, the executable will be much bigger because it will contain two variants of the library.

Only 1, 2, and 4 are valid. Any other value will produce a compilation error.