1 # <small>nlohmann::basic_json::</small>get_to
4 template<typename ValueType>
5 ValueType& get_to(ValueType& v) const noexcept(
6 noexcept(JSONSerializer<ValueType>::from_json(
7 std::declval<const basic_json_t&>(), v)));
10 Explicit type conversion between the JSON value and a compatible value. The value is filled into the input parameter by
11 calling the `json_serializer<ValueType>` `from_json()` method.
13 The function is equivalent to executing
16 JSONSerializer<ValueType>::from_json(*this, v);
19 This overload is chosen if:
21 - `ValueType` is not `basic_json`,
22 - `json_serializer<ValueType>` has a `from_json()` method of the form `void from_json(const basic_json&, ValueType&)`
24 ## Template parameters
27 : the value type to return
31 the input parameter, allowing chaining calls
35 Depends on what `json_serializer<ValueType>` `from_json()` method throws
41 The example below shows several conversions from JSON values to other types. There a few things to note: (1)
42 Floating-point numbers can be converted to integers, (2) A JSON array can be converted to a standard
43 `#!cpp std::vector<short>`, (3) A JSON object can be converted to C++ associative containers such as
44 `#cpp std::unordered_map<std::string, json>`.
47 --8<-- "examples/get_to.cpp"
53 --8<-- "examples/get_to.output"
58 - Since version 3.3.0.