mirror of
https://github.com/nlohmann/json.git
synced 2026-09-30 22:15:19 +00:00
- API pages for operator[], at, front, back, find, contains, count, begin, end, cbegin, cend, items, and type_name of basic_json_view, linked both ways with the basic_json pages - the feature page and size() describe document order and duplicate keys - the examples show when the view helps: reading a few fields of a large text, probing optional members, and members in source order Signed-off-by: Niels Lohmann <mail@nlohmann.me>
1.5 KiB
1.5 KiB
nlohmann::basic_json_view::end
iterator end() const noexcept;
Returns an iterator to one past the last element of an array, one past the last member value of an object, in
document order -- see begin(). A primitive value iterates as a range of one element (itself);
#!json null and a discarded view iterate as an empty range, so #!cpp begin() == end() for
them.
Return value
Iterator one past the last element.
Exception safety
No-throw guarantee: this function never throws exceptions.
Complexity
Constant.
Notes
#!cpp iterator is a forward iterator: unlike BasicJsonType::iterator, it cannot be decremented, so there is no
way to reach the last element by stepping back from end(). Use back() instead.
Examples
??? example
The example below scans a (possibly large) array of readings for the first one over a threshold, stopping the
loop at `end()` as soon as one is found. Only the matching reading, if any, is ever materialized.
```cpp
--8<-- "examples/basic_json_view__end.cpp"
```
Output:
```json
--8<-- "examples/basic_json_view__end.output"
```
See also
- begin - returns an iterator to the first element
- cend - returns a const iterator to one past the last element
BasicJsonType::end- the corresponding function ofbasic_json
Version history
- Added in version 3.13.0.