JSON for Modern C++ 3.10.4

◆ push_back() [1/2]

template<typename BasicJsonType >
void nlohmann::json_pointer< BasicJsonType >::push_back ( const std::string &  token)
inline
Parameters
[in]tokentoken to add
Complexity
Amortized constant.
Example
The example shows the result of push_back for different JSON Pointers.
1#include <iostream>
2#include <nlohmann/json.hpp>
3
4using json = nlohmann::json;
5
6int main()
7{
8 // create empty JSON Pointer
10 std::cout << ptr << '\n';
11
12 // call push_back()
13 ptr.push_back("foo");
14 std::cout << ptr << '\n';
15
16 ptr.push_back("0");
17 std::cout << ptr << '\n';
18
19 ptr.push_back("bar");
20 std::cout << ptr << '\n';
21}
::nlohmann::json_pointer< basic_json > json_pointer
JSON Pointer, see nlohmann::json_pointer.
Definition: json.hpp:17740
basic_json<> json
default JSON class
Definition: json.hpp:3472

Output (play with this example online):
""
"/foo"
"/foo/0"
"/foo/0/bar"
The example code above can be translated with
g++ -std=c++11 -Isingle_include doc/examples/json_pointer__push_back.cpp -o json_pointer__push_back 
Since
version 3.6.0

Definition at line 12748 of file json.hpp.