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

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

Result is false

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

See also