mirror of
https://github.com/nlohmann/json.git
synced 2025-07-28 12:02:00 +03:00
Consolidate documentation (#3071)
* 🔥 consolidate documentation * ♻️ overwork std specializations * 🚚 move images files to mkdocs * ♻️ fix URLs * 🔧 tweak MkDocs configuration * 🔧 add namespaces * 📝 document deprecations * 📝 document documentation generation * 🚸 improve search * 🚸 add examples * 🚧 start adding documentation for macros * 📝 add note for https://github.com/nlohmann/json/issues/874#issuecomment-1001699139 * 📝 overwork example handling * 📝 fix Markdown tables
This commit is contained in:
@ -27,7 +27,7 @@ The `#!cpp at()` member function performs checked access; that is, it returns a
|
||||
| `#!cpp j.at("hobbies").at(0)` | `#!json "hiking"` |
|
||||
| `#!cpp j.at("hobbies").at(1)` | `#!json "reading"` |
|
||||
|
||||
The return value is a reference, so it can be modify the original value.
|
||||
The return value is a reference, so it can be modified by the original value.
|
||||
|
||||
??? example
|
||||
|
||||
@ -69,9 +69,9 @@ When accessing an invalid index (i.e., an index greater than or equal to the arr
|
||||
|
||||
## Summary
|
||||
|
||||
| scenario | non-const value | const value |
|
||||
| -------- | ------------- | ----------- |
|
||||
| access to existing object key | reference to existing value is returned | const reference to existing value is returned |
|
||||
| access to valid array index | reference to existing value is returned | const reference to existing value is returned |
|
||||
| scenario | non-const value | const value |
|
||||
|-----------------------------------|------------------------------------------------|------------------------------------------------|
|
||||
| access to existing object key | reference to existing value is returned | const reference to existing value is returned |
|
||||
| access to valid array index | reference to existing value is returned | const reference to existing value is returned |
|
||||
| access to non-existing object key | `basic_json::out_of_range` exception is thrown | `basic_json::out_of_range` exception is thrown |
|
||||
| access to invalid array index | `basic_json::out_of_range` exception is thrown | `basic_json::out_of_range` exception is thrown |
|
||||
| access to invalid array index | `basic_json::out_of_range` exception is thrown | `basic_json::out_of_range` exception is thrown |
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Overview
|
||||
# Element Access
|
||||
|
||||
There are many ways elements in a JSON value can be accessed:
|
||||
|
||||
|
@ -27,7 +27,7 @@ Elements in a JSON object and a JSON array can be accessed via `#!cpp operator[]
|
||||
| `#!cpp j["hobbies"][0]` | `#!json "hiking"` |
|
||||
| `#!cpp j["hobbies"][1]` | `#!json "reading"` |
|
||||
|
||||
The return value is a reference, so it can be modify the original value. In case the passed object key is non-existing, a `#!json null` value is inserted which can be immediately be overwritten.
|
||||
The return value is a reference, so it can modify the original value. In case the passed object key is non-existing, a `#!json null` value is inserted which can be immediately be overwritten.
|
||||
|
||||
??? example
|
||||
|
||||
@ -94,9 +94,9 @@ When accessing an invalid index (i.e., an index greater than or equal to the arr
|
||||
|
||||
## Summary
|
||||
|
||||
| scenario | non-const value | const value |
|
||||
| -------- | ------------- | ----------- |
|
||||
| access to existing object key | reference to existing value is returned | const reference to existing value is returned |
|
||||
| access to valid array index | reference to existing value is returned | const reference to existing value is returned |
|
||||
| access to non-existing object key | reference to newly inserted `#!json null` value is returned | **undefined behavior**; assertion in debug mode |
|
||||
| access to invalid array index | reference to newly inserted `#!json null` value is returned; any index between previous maximal index and passed index are filled with `#!json null` | **undefined behavior**; assertion in debug mode |
|
||||
| scenario | non-const value | const value |
|
||||
|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------|
|
||||
| access to existing object key | reference to existing value is returned | const reference to existing value is returned |
|
||||
| access to valid array index | reference to existing value is returned | const reference to existing value is returned |
|
||||
| access to non-existing object key | reference to newly inserted `#!json null` value is returned | **undefined behavior**; assertion in debug mode |
|
||||
| access to invalid array index | reference to newly inserted `#!json null` value is returned; any index between previous maximal index and passed index are filled with `#!json null` | **undefined behavior**; assertion in debug mode |
|
||||
|
Reference in New Issue
Block a user