The single features/json_view.md page grew to ~600 lines covering eight
topics. Split it into features/json_view/ with an overview page and
pages for ownership and lifetime, differences from basic_json, reading
values, generic code, editing, and images.
The new differences page collects what was spread over several sections
("What is the same", "What is different", "Duplicate keys", and notes in
the conversion and serialization sections) under one summary table, and
adds the parts of the basic_json interface a view does not have. The
other pages now link to it instead of restating the rules.
Internal links across the documentation point to the new pages.
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
1.2 KiB
1.2 KiB
nlohmann::basic_json_document::node_count
std::size_t node_count() const noexcept;
Returns the number of entries in the document's flat index.
Return value
The number of index entries: one per value (of any type, at any nesting depth) plus one per object key. 0 for a
discarded document.
Exception safety
No-throw guarantee: this function never throws exceptions.
Complexity
Constant.
Notes
Each index entry is 16 bytes, so #!cpp node_count() * 16 is
the size of the index itself (part, but not all, of memory_usage(), which also counts decoded
strings and, for an owned document, the text).
Examples
??? example
```cpp
--8<-- "examples/basic_json_document__node_count.cpp"
```
Output:
```json
--8<-- "examples/basic_json_document__node_count.output"
```
See also
memory_usage- the number of bytes held by the documentshrink_to_fit- release unused index capacity- Zero-copy JSON views - the flat node index and its memory
Version history
- Added in version 3.13.0.