]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/third_party/nlohmann-json/doc/mkdocs/docs/api/basic_json/flatten.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 / flatten.md
1 # <small>nlohmann::basic_json::</small>flatten
2
3 ```cpp
4 basic_json flatten() const;
5 ```
6
7 The function creates a JSON object whose keys are JSON pointers (see [RFC 6901](https://tools.ietf.org/html/rfc6901))
8 and whose values are all primitive (see [`is_primitive()`](is_primitive.md) for more information). The original JSON
9 value can be restored using the [`unflatten()`](unflatten.md) function.
10
11 ## Return value
12
13 an object that maps JSON pointers to primitive values
14
15 ## Exception safety
16
17 Strong exception safety: if an exception occurs, the original value stays intact.
18
19 ## Complexity
20
21 Linear in the size the JSON value.
22
23 ## Notes
24
25 Empty objects and arrays are flattened to `#!json null` and will not be reconstructed correctly by the
26 [`unflatten()`](unflatten.md) function.
27
28 ## Examples
29
30 ??? example
31
32 The following code shows how a JSON object is flattened to an object whose keys consist of JSON pointers.
33
34 ```cpp
35 --8<-- "examples/flatten.cpp"
36 ```
37
38 Output:
39
40 ```json
41 --8<-- "examples/flatten.output"
42 ```
43
44 ## See also
45
46 - [unflatten](unflatten.md) the reverse function
47
48 ## Version history
49
50 - Added in version 2.0.0.