If the root of the JsonDocument
is an object, JsonDocument::size()
returns the number of key-value pairs in the object (same as JsonObject::size()
)
If the root of the JsonDocument
is an array, JsonDocument::size()
returns the number of elements in the array (same as JsonArray::size()
)
In all other cases, JsonDocument::size()
returns 0
Internally, this function walks a linked-list to count the elements, so its time complexity is O(n).
Don’t confuse JsonDocument::size()
with JsonDocument::memoryUsage()
.
StaticJsonDocument<200> doc;
object["hello"] = "world";
Serial.println(object.size()); // 1
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