Renderd7-nightly v0.7.0

List of all members
nlohmann::detail::type_error Class Reference

exception indicating executing a member function with a wrong type More...

`#include <json.hpp>`

Inheritance diagram for nlohmann::detail::type_error:

## Additional Inherited Members
Public Member Functions inherited from nlohmann::detail::exception
const JSON_HEDLEY_RETURNS_NON_NULL char * | what () const noexcept override
| returns the explanatory string
Public Attributes inherited from nlohmann::detail::exception
const int | id
| the id of the exception

## Detailed Description

exception indicating executing a member function with a wrong type

This exception is thrown in case of a type error; that is, a library function is executed on a JSON value whose type does not match the expected semantics.

Exceptions have ids 3xx.

name / id | example message | description
--- | --- | ---
json.exception.type_error.301 | cannot create object from initializer list | To create an object from an initializer list, the initializer list must consist only of a list of pairs whose first element is a string. When this constraint is violated, an array is created instead.
json.exception.type_error.302 | type must be object, but is array | During implicit or explicit value conversion, the JSON type must be compatible to the target type. For instance, a JSON string can only be converted into string types, but not into numbers or boolean types.
json.exception.type_error.303 | incompatible ReferenceType for get_ref, actual type is object | To retrieve a reference to a value stored in a basic_json object with get_ref, the type of the reference must match the value type. For instance, for a JSON array, the ReferenceType must be array_t &.
json.exception.type_error.304 | cannot use at() with string | The at() member functions can only be executed for certain JSON types.
json.exception.type_error.305 | cannot use operator[] with string | The operator[] member functions can only be executed for certain JSON types.
json.exception.type_error.306 | cannot use value() with string | The value() member functions can only be executed for certain JSON types.
json.exception.type_error.307 | cannot use erase() with string | The erase() member functions can only be executed for certain JSON types.
json.exception.type_error.308 | cannot use push_back() with string | The push_back() and operator+= member functions can only be executed for certain JSON types.
json.exception.type_error.309 | cannot use insert() with | The insert() member functions can only be executed for certain JSON types.
json.exception.type_error.310 | cannot use swap() with number | The swap() member functions can only be executed for certain JSON types.
json.exception.type_error.311 | cannot use emplace_back() with string | The emplace_back() member function can only be executed for certain JSON types.
json.exception.type_error.312 | cannot use update() with string | The update() member functions can only be executed for certain JSON types.
json.exception.type_error.313 | invalid value to unflatten | The unflatten function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well defined.
json.exception.type_error.314 | only objects can be unflattened | The unflatten function only works for an object whose keys are JSON Pointers.
json.exception.type_error.315 | values in object must be primitive | The unflatten function only works for an object whose keys are JSON Pointers and whose values are primitive.
json.exception.type_error.316 | invalid UTF-8 byte at index 10: 0x7E | The dump function only works with UTF-8 encoded strings; that is, if you assign a `std::string` to a JSON value, make sure it is UTF-8 encoded.
json.exception.type_error.317 | JSON value cannot be serialized to requested format | The dynamic type of the object cannot be represented in the requested serialization format (e.g. a raw `true` or `null` JSON object cannot be serialized to BSON)

@liveexample{The following code shows how a `type_error` exception can be caught.,type_error}

See also
  - exception for the base class of the library exceptions
  - parse_error for exceptions indicating a parse error
  - invalid_iterator for exceptions indicating errors with iterators
  - out_of_range for exceptions indicating access out of the defined range
  - other_error for exceptions indicating other library errors

Since
  version 3.0.0