Description

Defines the maximum number of nested object and array allowed when a JSON document is deserialize. This is a security feature to prevent stack overflow.

deserializeJson() and deserializeMsgPack() both calls a recursive function. Each time an array or an object is opened in the input document, the recursive function calls itself. As a consequence, the memory consumption (more specifically the stack memory consumption) is proportional to the number of nesting level (the deepness if you prefer) of the input document. ArduinoJson limits the number of nesting level to prevent a stack overflow that a deep input document would cause.

Signature

uint8_t nestingLimit;

Example

StaticJsonDocument<200> doc;
char json[] = "[[[42]]]";

doc.nestingLimit = 10:
deserializeJson(doc, json); // return DeserializationError::Ok

doc.nestingLimit = 2;
deserializeJson(doc, json); // returns DeserializationError::TooDeep

See also