]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/third_party/nlohmann-json/doc/mkdocs/docs/api/basic_json/get_to.md
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / third_party / nlohmann-json / doc / mkdocs / docs / api / basic_json / get_to.md
1 # <small>nlohmann::basic_json::</small>get_to
2
3 ```cpp
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)));
8 ```
9
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.
12
13 The function is equivalent to executing
14 ```cpp
15 ValueType v;
16 JSONSerializer<ValueType>::from_json(*this, v);
17 ```
18
19 This overload is chosen if:
20
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&)`
23
24 ## Template parameters
25
26 `ValueType`
27 : the value type to return
28
29 ## Return value
30
31 the input parameter, allowing chaining calls
32
33 ## Exceptions
34
35 Depends on what `json_serializer<ValueType>` `from_json()` method throws
36
37 ## Examples
38
39 ??? example
40
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>`.
45
46 ```cpp
47 --8<-- "examples/get_to.cpp"
48 ```
49
50 Output:
51
52 ```json
53 --8<-- "examples/get_to.output"
54 ```
55
56 ## Version history
57
58 - Since version 3.3.0.