mirror of
https://github.com/nlohmann/json.git
synced 2025-07-29 23:01:16 +03:00
allow push_back() and pop_back() calls on json_pointer
Putting pop_back() to public and creating a trivial push_back() method allows users of nlohmann::json_pointer to manipulate an existing json-pointer by adding or removing keys at the end. This is useful for traversing a JSON-instance and keeping track of its "absolute path" at any moment. In my case for a schema-validator error-handler.
This commit is contained in:
@ -11885,7 +11885,6 @@ class json_pointer
|
||||
return res;
|
||||
}
|
||||
|
||||
private:
|
||||
/*!
|
||||
@brief remove and return last reference pointer
|
||||
@throw out_of_range.405 if JSON pointer has no parent
|
||||
@ -11902,6 +11901,16 @@ class json_pointer
|
||||
return last;
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief remove and return last reference pointer
|
||||
@throw out_of_range.405 if JSON pointer has no parent
|
||||
*/
|
||||
void push_back(const std::string& tok)
|
||||
{
|
||||
reference_tokens.push_back(tok);
|
||||
}
|
||||
|
||||
private:
|
||||
/// return whether pointer points to the root document
|
||||
bool is_root() const noexcept
|
||||
{
|
||||
|
Reference in New Issue
Block a user