]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/third_party/nlohmann-json/doc/mkdocs/docs/api/basic_json/operator_literal_json.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 / operator_literal_json.md
1 # <small>nlohmann::basic_json::</small>operator""_json
2
3 ```cpp
4 json operator "" _json(const char* s, std::size_t n);
5 ```
6
7 This operator implements a user-defined string literal for JSON objects. It can be used by adding `#!cpp _json` to a
8 string literal and returns a [`json`](../json.md) object if no parse error occurred.
9
10 ## Parameters
11
12 `s` (in)
13 : a string representation of a JSON object
14
15 `n` (in)
16 : length of string `s`
17
18 ## Return value
19
20 [`json`](../json.md) value parsed from `s`
21
22 ## Exceptions
23
24 The function can throw anything that [`parse(s, s+n)`](parse.md) would throw.
25
26 ## Complexity
27
28 Linear.
29
30 ## Examples
31
32 ??? example
33
34 The following code shows how to create JSON values from string literals.
35
36 ```cpp
37 --8<-- "examples/operator_literal_json.cpp"
38 ```
39
40 Output:
41
42 ```json
43 --8<-- "examples/operator_literal_json.output"
44 ```
45
46 ## Version history
47
48 - Added in version 1.0.0.