Description

JsonVariant::isNull() tells whether the variant points to a value or not.

Remember that a JsonVariant is a reference to a value in a JsonDocument. A JsonVariant that is not attached to a JsonDocument will always be null:

JsonVariant variant;
variant.set(42); // does nothing because the variant is not attached to a document
variant.isNull(); // returns true

Signature

bool isNull() const;

Return value

JsonVariant::isNull() returns a bool that tells if the JsonVariant points to something or not:

Example

DynamicJsonDocument doc(1024);
deserializeJson("{\"a\":1,\"b\":null}");

doc["a"].isNull(); // false, because doc["a"] contains 1
doc["b"].isNull(); // true, because doc["b"] contains null
doc["c"].isNull(); // true, because doc["c"] doesn't exist

See also