A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://arduinojson.org/v6/api/jsonarray/begin_end/ below:

JsonArray::begin() / JsonArray::end()

Description

The member functions begin() and end() return STL-style iterators. You can use these iterators to enumerate all the elements in the array pointed by the JsonArray.

These functions reproduce the containers in the C++ Standard Library and allow you to use the “ranged-based for loop” feature of C++11. See the example below.

Signatures
JsonArray::iterator begin() const;
JsonArray::iterator end() const;
Return value

begin() returns an iterator to the first element of the array.

end() returns an iterator to the element after the last. This iterator must not be dereferenced because it is out of the array. It’s a placeholder to detect the end of the array.

JsonArray::iterator points to a JsonVariant. You can dereference the iterator with the usual * and -> operators.

Example
char json[] = "[\"one\",\"two\",\"three\"]";
DynamicJsonDocument doc(1024);
deserializeJson(doc, json);
JsonArray arr = doc.as<JsonArray>();

for (JsonVariant value : arr) {
    Serial.println(value.as<const char*>());
}

The code above would print:

See also
  1. Home
  2. Version 6
  3. API
  4. JsonArray
  5. begin() & end()

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