]>
Commit | Line | Data |
---|---|---|
1e59de90 TL |
1 | # <small>nlohmann::json_pointer::</small>json_pointer |
2 | ||
3 | ```cpp | |
4 | explicit json_pointer(const std::string& s = ""); | |
5 | ``` | |
6 | ||
7 | Create a JSON pointer according to the syntax described in | |
8 | [Section 3 of RFC6901](https://tools.ietf.org/html/rfc6901#section-3). | |
9 | ||
10 | ## Parameters | |
11 | ||
12 | `s` (in) | |
13 | : string representing the JSON pointer; if omitted, the empty string is assumed which references the whole JSON value | |
14 | ||
15 | ## Exceptions | |
16 | ||
17 | - Throws [parse_error.107](../../home/exceptions.md#jsonexceptionparse_error107) if the given JSON pointer `s` is | |
18 | nonempty and does not begin with a slash (`/`); see example below. | |
19 | - Throws [parse_error.108](../../home/exceptions.md#jsonexceptionparse_error108) if a tilde (`~`) in the given JSON | |
20 | pointer `s` is not followed by `0` (representing `~`) or `1` (representing `/`); see example below. | |
21 | ||
22 | ## Examples | |
23 | ||
24 | ??? example | |
25 | ||
26 | The example shows the construction several valid JSON pointers as well as the exceptional behavior. | |
27 | ||
28 | ```cpp | |
29 | --8<-- "examples/json_pointer.cpp" | |
30 | ``` | |
31 | ||
32 | Output: | |
33 | ||
34 | ```json | |
35 | --8<-- "examples/json_pointer.output" | |
36 | ``` | |
37 | ||
38 | ## Version history | |
39 | ||
40 | Added in version 2.0.0. |