|
static int | array_index (const std::string &s) |
|
static std::vector< std::string > | split (const std::string &reference_string) |
| split the string input to reference tokens More...
|
|
static void | replace_substring (std::string &s, const std::string &f, const std::string &t) |
| replace all occurrences of a substring by another string More...
|
|
static std::string | escape (std::string s) |
| escape "~" to "~0" and "/" to "~1" More...
|
|
static void | unescape (std::string &s) |
| unescape "~1" to tilde and "~0" to slash (order is important!) More...
|
|
static void | flatten (const std::string &reference_string, const BasicJsonType &value, BasicJsonType &result) |
|
static BasicJsonType | unflatten (const BasicJsonType &value) |
|
template<typename BasicJsonType>
class nlohmann::json_pointer< BasicJsonType >
JSON Pointer.
A JSON pointer defines a string syntax for identifying a specific value within a JSON document. It can be used with functions at
and operator[]
. Furthermore, JSON pointers are the base for JSON patches.
- See also
- RFC 6901
- Since
- version 2.0.0
Definition at line 8427 of file json.hpp.
template<typename BasicJsonType >
create JSON pointer
Create a JSON pointer according to the syntax described in Section 3 of RFC6901.
- Parameters
-
[in] | s | string representing the JSON pointer; if omitted, the empty string is assumed which references the whole JSON value |
- Exceptions
-
parse_error.107 | if the given JSON pointer s is nonempty and does not begin with a slash (/ ); see example below |
parse_error.108 | if a tilde (~ ) in the given JSON pointer s is not followed by 0 (representing ~ ) or 1 (representing / ); see example below |
@liveexample{The example shows the construction several valid JSON pointers as well as the exceptional behavior.,json_pointer}
- Since
- version 2.0.0
Definition at line 8455 of file json.hpp.
template<typename BasicJsonType >
return whether pointer points to the root document
- Returns
- true iff the JSON pointer points to the root document
@complexity Constant.
@exceptionsafety No-throw guarantee: this function never throws exceptions.
@liveexample{The example shows the result of empty
for different JSON Pointers.,json_pointer__empty}
- Since
- version 3.6.0
Definition at line 8726 of file json.hpp.
template<typename BasicJsonType >
returns the parent of this JSON pointer
- Returns
- parent of this JSON pointer; in case this JSON pointer is the root, the root itself is returned
@complexity Linear in the length of the JSON pointer.
@liveexample{The example shows the result of parent_pointer
for different JSON Pointers.,json_pointer__parent_pointer}
- Since
- version 3.6.0
Definition at line 8630 of file json.hpp.
template<typename BasicJsonType >
append an unescaped token at the end of the reference pointer
- Parameters
-
@complexity Amortized constant.
@liveexample{The example shows the result of push_back
for different JSON Pointers.,json_pointer__push_back}
- Since
- version 3.6.0
Definition at line 8701 of file json.hpp.
template<typename BasicJsonType >
append an unescaped token at the end of the reference pointer
- Parameters
-
@complexity Amortized constant.
@liveexample{The example shows the result of push_back
for different JSON Pointers.,json_pointer__push_back}
- Since
- version 3.6.0
Definition at line 8707 of file json.hpp.
template<typename BasicJsonType >
compares two JSON pointers for inequality
- Parameters
-
[in] | lhs | JSON pointer to compare |
[in] | rhs | JSON pointer to compare |
- Returns
- whether lhs is not equal rhs
@complexity Linear in the length of the JSON pointer
@exceptionsafety No-throw guarantee: this function never throws exceptions.
Definition at line 9340 of file json.hpp.
template<typename BasicJsonType >
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
- Parameters
-
[in] | lhs | JSON pointer |
[in] | rhs | JSON pointer |
- Returns
- a new JSON pointer with rhs appended to lhs
@liveexample{The example shows the usage of operator/
.,json_pointer__operator_add_binary}
@complexity Linear in the length of lhs and rhs.
- See also
- operator/=(const json_pointer&) to append a JSON pointer
- Since
- version 3.6.0
Definition at line 8571 of file json.hpp.
template<typename BasicJsonType >
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
- Parameters
-
[in] | ptr | JSON pointer |
[in] | array_index | array index |
- Returns
- a new JSON pointer with array_index appended to ptr
@liveexample{The example shows the usage of operator/
.,json_pointer__operator_add_binary}
@complexity Linear in the length of ptr.
- See also
- operator/=(std::size_t) to append an array index
- Since
- version 3.6.0
Definition at line 8612 of file json.hpp.
template<typename BasicJsonType >
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
- Parameters
-
[in] | ptr | JSON pointer |
[in] | token | reference token |
- Returns
- a new JSON pointer with unescaped token appended to ptr
@liveexample{The example shows the usage of operator/
.,json_pointer__operator_add_binary}
@complexity Linear in the length of ptr.
- See also
- operator/=(std::string) to append a reference token
- Since
- version 3.6.0
Definition at line 8592 of file json.hpp.
template<typename BasicJsonType >
compares two JSON pointers for equality
- Parameters
-
[in] | lhs | JSON pointer to compare |
[in] | rhs | JSON pointer to compare |
- Returns
- whether lhs is equal to rhs
@complexity Linear in the length of the JSON pointer
@exceptionsafety No-throw guarantee: this function never throws exceptions.
Definition at line 9323 of file json.hpp.