JSON for Modern C++
3.9.1
|
These pages contain the API documentation of JSON for Modern C++, a C++11 header-only JSON class.
basic_json
– class template for JSON valuesjson
– the default specialization of basic_json
, defined as basic_json<>
The container functions known from STL have been extended to support the different value types from JSON. However, not all functions can be applied to all value types. Note that the signature of some functions differ between the types; for instance, at
may be called with either a string to address a key in an object or with an integer to address a value in an array.
Note that this table only lists those exceptions thrown due to the type. For instance, the at
function will always throw a json::type_error
exception when called for a string type. When called for an array, it may throw an json::out_of_range
exception if the passed index is invalid.
group | function | JSON value type | |||||
---|---|---|---|---|---|---|---|
object | array | string | number | boolean | null | ||
iterators | begin | begin | begin | begin | begin | begin | begin (returns end() ) |
cbegin | cbegin | cbegin | cbegin | cbegin | cbegin | cbegin (returns cend() ) | |
end | end | end | end | end | end | end | |
cend | cend | cend | cend | cend | cend | cend | |
rbegin | rbegin | rbegin | rbegin | rbegin | rbegin | rbegin | |
crbegin | crbegin | crbegin | crbegin | crbegin | crbegin | crbegin | |
rend | rend | rend | rend | rend | rend | rend | |
crend | crend | crend | crend | crend | crend | crend | |
element access | at | at | at | throws json::type_error (304) | throws json::type_error (304) | throws json::type_error (304) | throws json::type_error (304) |
operator[] | operator[] | operator[] | throws json::type_error (305) | throws json::type_error (305) | throws json::type_error (305) | operator[] (creates object)operator[] (creates array) | |
front | front | front | front | front | front | throws json::invalid_iterator (214) | |
back | back | back | back | back | back | throws json::invalid_iterator (214) | |
capacity | empty | empty | empty | empty (returns false ) | empty (returns false ) | empty (returns false ) | empty (returns true ) |
size | size | size | size (returns 1 ) | size (returns 1 ) | size (returns 1 ) | size (returns 0 ) | |
max_size_ | max_size | max_size | max_size (returns 1 ) | max_size (returns 1 ) | max_size (returns 1 ) | max_size (returns 0 ) | |
modifiers | clear | clear | clear | clear | clear | clear | clear |
insert | throws json::type_error (309) | insert | throws json::type_error (309) | throws json::type_error (309) | throws json::type_error (309) | throws json::type_error (309) | |
erase | erase | erase | erase (converts to null) | erase (converts to null) | erase (converts to null) | throws json::type_error (307) | |
push_back | push_back | push_back | throws json::type_error (308) | throws json::type_error (308) | throws json::type_error (308) | push_back (creates object)push_back (creates array) | |
emplace / emplace_back | emplace | emplace_back | throws json::type_error (311) | throws json::type_error (311) | throws json::type_error (311) | emplace (creates object)emplace_back (creates array) | |
update | update | throws json::type_error (312) | throws json::type_error (312) | throws json::type_error (312) | throws json::type_error (312) | throws json::type_error (312) | |
swap | swap | swap | swap | swap | swap | swap | |
lookup | find | find | find (returns end() ) | find (returns end() ) | find (returns end() ) | find (returns end() ) | find (returns end() ) |
count | count | count (returns 0 ) | count (returns 0 ) | count (returns 0 ) | count (returns 0 ) | count (returns 0 ) | |
contains | contains | contains (returns false ) | contains (returns false ) | contains (returns false ) | contains (returns false ) | contains (returns false ) |