mirror of
https://github.com/nlohmann/json.git
synced 2026-10-13 09:47:12 +00:00
deploy: 40a62947d3
This commit is contained in:
1 parent
79119509a9
commit
22fba27145
555 files changed
+17342
-1394
No files matched your search
@@ -52,13 +52,40 @@ json_pointer& operator/=(std::size_t array_idx)
|
||||
The example shows the usage of `operator/=`.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/json_pointer__operator_add.cpp"
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create a JSON pointer
|
||||
json::json_pointer ptr("/foo");
|
||||
std::cout << "\"" << ptr << "\"\n";
|
||||
|
||||
// append a JSON Pointer
|
||||
ptr /= json::json_pointer("/bar/baz");
|
||||
std::cout << "\"" << ptr << "\"\n";
|
||||
|
||||
// append a string
|
||||
ptr /= "fob";
|
||||
std::cout << "\"" << ptr << "\"\n";
|
||||
|
||||
// append an array index
|
||||
ptr /= 42;
|
||||
std::cout << "\"" << ptr << "\"" << std::endl;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/json_pointer__operator_add.output"
|
||||
"/foo"
|
||||
"/foo/bar/baz"
|
||||
"/foo/bar/baz/fob"
|
||||
"/foo/bar/baz/fob/42"
|
||||
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
Reference in new issue
Block a user