File: get.md

package info (click to toggle)
jsoncons 1.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 17,584 kB
  • sloc: cpp: 136,382; sh: 33; makefile: 5
file content (39 lines) | stat: -rw-r--r-- 1,001 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
### jsoncons::jsonpath::get

```cpp
#include <jsoncons_ext/jsonpath/jsonpath.hpp>

template <typename Json>
Json* get(Json& root, const basic_json_location<Json::char_type>& location);                   (until 0.175.0)

template <typename Json>
std::pair<Json*,bool> get(Json& root, const basic_json_location<Json::char_type>& location);   (since 0.175.0)
```

Gets a pointer to a JSON value in a JSON document at a specified location.

#### Parameters
<table>
  <tr>
    <td>root</td>
    <td>Root JSON value</td> 
  </tr>
  <tr>
    <td>location</td>
    <td>A <a href="basic_json_location.md">basic_json_location</a></td> 
  </tr>
</table>

#### Return value

Until 0.175.0, returns a pointer to the selected item, or null if not found. 

Since 0.175.0, returns a `std::pair<Json*,bool>`. If the get operation succeeded, the bool component is `true`, and
the `Json*` component points to the value in the `root`. If the get operation failed, the bool component is `false`.


### Exceptions

None.