Json.at
// 1
Json& at(const Str& key);
// 2
const Json& at(const Str& key) const;
// 3
Json& at(const std::size_t index);
// 4
const Json& at(const std::size_t index) const;
- Accesses object member by key - returns mutable reference, throws on invalid key
- Accesses object member by key - returns const reference, throws on invalid key
- Accesses array element by index - returns mutable reference, throws on out-of-bounds
- Accesses array element by index - returns const reference, throws on out-of-bounds
Exception Safety
- Throws std::bad_variant_access
if underlying data isn't Obj/Arr
- Throws std::out_of_range
for invalid keys/indices
Complexity - Arr access: O(1) - Obj access: O(logN) (ordered map) / amortized O(1) (hash map)
Version
Since v3.0.0 .