JSON for Modern C++ 3.10.3

◆ pop_back()

template<typename BasicJsonType >
void nlohmann::json_pointer< BasicJsonType >::pop_back ( )
inline
Precondition
not empty()
Example
The example shows the usage of pop_back.
1#include <iostream>
2#include <nlohmann/json.hpp>
3
4using json = nlohmann::json;
5
6int main()
7{
8 // create empty JSON Pointer
9 json::json_pointer ptr("/foo/bar/baz");
10 std::cout << ptr << '\n';
11
12 // call pop_back()
13 ptr.pop_back();
14 std::cout << ptr << '\n';
15
16 ptr.pop_back();
17 std::cout << ptr << '\n';
18
19 ptr.pop_back();
20 std::cout << ptr << '\n';
21}
::nlohmann::json_pointer< basic_json > json_pointer
JSON Pointer, see nlohmann::json_pointer.
Definition: json.hpp:17726
basic_json<> json
default JSON class
Definition: json.hpp:3472

Output (play with this example online):
"/foo/bar/baz"
"/foo/bar"
"/foo"
""
The example code above can be translated with
g++ -std=c++11 -Isingle_include doc/examples/json_pointer__pop_back.cpp -o json_pointer__pop_back 
Complexity
Constant.
Exceptions
out_of_range.405if JSON pointer has no parent
Since
version 3.6.0

Definition at line 12689 of file json.hpp.