mirror of
https://github.com/nlohmann/json.git
synced 2026-07-09 12:05:10 +00:00
deploy: 7c9208bfb3
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
# nlohmann::json_pointer::empty
|
||||
|
||||
```
|
||||
bool empty() const noexcept;
|
||||
```
|
||||
|
||||
Return whether the pointer points to the root document.
|
||||
|
||||
## Return value
|
||||
|
||||
`true` iff the JSON pointer points to the root document.
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Examples
|
||||
|
||||
Example
|
||||
|
||||
The example shows the result of `empty` for different JSON Pointers.
|
||||
|
||||
```
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// different JSON Pointers
|
||||
json::json_pointer ptr0;
|
||||
json::json_pointer ptr1("");
|
||||
json::json_pointer ptr2("/foo");
|
||||
json::json_pointer ptr3("/foo/0");
|
||||
|
||||
// call empty()
|
||||
std::cout << std::boolalpha
|
||||
<< "\"" << ptr0 << "\": " << ptr0.empty() << '\n'
|
||||
<< "\"" << ptr1 << "\": " << ptr1.empty() << '\n'
|
||||
<< "\"" << ptr2 << "\": " << ptr2.empty() << '\n'
|
||||
<< "\"" << ptr3 << "\": " << ptr3.empty() << std::endl;
|
||||
}
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```
|
||||
"": true
|
||||
"": true
|
||||
"/foo": false
|
||||
"/foo/0": false
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
Added in version 3.6.0.
|
||||
Reference in New Issue
Block a user