ArduinoJson 7 uses integers to store the length of strings. The width of the integers depends on the CPU architecture.

CPU architecture Bytes for length Max characters
8-bit 1 255
32-bit 2 65,635
64-bit 2 65,635

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

For example, you can set ARDUINOJSON_STRING_LENGTH_SIZE if you need to store strings longer than 65,635 characters:

#define ARDUINOJSON_STRING_LENGTH_SIZE 4
#include <ArduinoJson.h>

You can simulate the effect of changing ARDUINOJSON_STRING_LENGTH_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_STRING_LENGTH_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.