JsonArray::isNull()
tells whether the JsonArray
points to an array or not.
You can use this function to:
As an alternative, you can use the conversion to bool
; for example, if(array)
instead of if(!array.isNull())
JsonArray::isNull()
returns a bool
that tells if the JsonArray
points to something:
Example 1: parsing success:
StaticJsonDocument<200> doc;
deserializeJson(doc, "[1,2]");
JsonArray array = doc.as<JsonArray>();
Serial.println(array.isNull()); // false
Example 2: parsing failure:
StaticJsonDocument<200> doc;
deserializeJson(doc, "{1,2}");
JsonArray array = doc.as<JsonArray>();
Serial.println(array.isNull()); // true
Example 3: allocation success:
StaticJsonDocument<200> doc;
JsonArray array = doc.to<JsonArray>();
Serial.println(array.isNull()); // false
Example 4: allocation failure:
StaticJsonDocument<1> doc;
JsonArray array = doc.to<JsonArray>();
Serial.println(array.isNull()); // true
See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4