Description

JsonDocument::isNull() tells whether the JsonDocument is empty, i.e. if the document’s root is null.

Signature

bool isNull() const;

Return value

JsonDocument::isNull() returns a bool that tells if the JsonDocument is empty:

Example

Result is true

DynamicJsonDocument doc(1024);
doc.isNull(); // true
serializeJson(doc, Serial); // prints "null"

Result is false

DynamicJsonDocument doc(1024);
doc.to<JsonArray>();
doc.isNull(); // false
serializeJson(doc, Serial); // prints "[]"

See also

Global warming stripes by Professor Ed Hawkins (University of Reading)