mirror of
https://github.com/nlohmann/json.git
synced 2024-11-28 00:59:02 +08:00
Add json_pointer::parent_pointer (cf. std::filesystem::path::parent_path)
This commit is contained in:
parent
164e0e54d9
commit
08de9eeaca
@ -122,6 +122,21 @@ class json_pointer
|
||||
return json_pointer(lhs) /= array_index;
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief create a new JSON pointer that is the parent of this JSON pointer
|
||||
*/
|
||||
json_pointer parent_pointer() const
|
||||
{
|
||||
if (empty())
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
json_pointer res = *this;
|
||||
res.pop_back();
|
||||
return res;
|
||||
}
|
||||
|
||||
/*!
|
||||
@param[in] s reference token to be converted into an array index
|
||||
|
||||
|
@ -11932,6 +11932,21 @@ class json_pointer
|
||||
return json_pointer(lhs) /= array_index;
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief create a new JSON pointer that is the parent of this JSON pointer
|
||||
*/
|
||||
json_pointer parent_pointer() const
|
||||
{
|
||||
if (empty())
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
json_pointer res = *this;
|
||||
res.pop_back();
|
||||
return res;
|
||||
}
|
||||
|
||||
/*!
|
||||
@param[in] s reference token to be converted into an array index
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user