Public Member Functions |
| json_pointer (const std::string &s="") |
| create JSON pointer
|
| operator std::string () const |
std::string | to_string () const noexcept |
| return a string representation of the JSON pointer
|
Private Member Functions |
reference | get_and_create (reference j) const |
| create and return a reference to the pointed to value
|
reference | get_checked (pointer ptr) const |
const_reference | get_checked (const_pointer ptr) const |
reference | get_unchecked (pointer ptr) const |
| return a reference to the pointed to value
|
const_reference | get_unchecked (const_pointer ptr) const |
| return a const reference to the pointed to value
|
bool | is_root () const |
| return whether pointer points to the root document
|
std::string | pop_back () |
| remove and return last reference pointer
|
json_pointer | top () const |
Static Private Member Functions |
static std::string | escape (std::string s) |
| escape tilde and slash
|
static void | flatten (const std::string &reference_string, const basic_json &value, basic_json &result) |
static void | replace_substring (std::string &s, const std::string &f, const std::string &t) |
| replace all occurrences of a substring by another string
|
static std::vector< std::string > | split (std::string reference_string) |
| split the string input to reference tokens
|
static void | unescape (std::string &s) |
| unescape tilde and slash
|
static basic_json | unflatten (const basic_json &value) |
Friends |
class | basic_json |
| allow basic_json to access private members
|
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
class nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer
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](https://tools.ietf.org/html/rfc6901)
- Since:
- version 2.0.0
Definition at line 8728 of file json.hpp.
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
create JSON pointer
Create a JSON pointer according to the syntax described in [Section 3 of RFC6901](https://tools.ietf.org/html/rfc6901#section-3).
- Parameters:
-
[in] | s | string representing the JSON pointer; if omitted, the empty string is assumed which references the whole JSON value |
- Exceptions:
-
std::domain_error | if reference token is nonempty and does not begin with a slash (`/`); example: `"JSON pointer must be empty or
begin with /"` |
std::domain_error | if a tilde (`~`) is not followed by `0` (representing `~`) or `1` (representing `/`); example: `"escape error:
~ must be followed with 0 or 1"` |
{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 8756 of file json.hpp.
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
static std::string nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::escape |
( |
std::string |
s | ) |
[inline, static, private] |
escape tilde and slash
Definition at line 9172 of file json.hpp.
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
static void nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::flatten |
( |
const std::string & |
reference_string, |
|
|
const basic_json & |
value, |
|
|
basic_json & |
result |
|
) |
| [inline, static, private] |
- Parameters:
-
[in] | reference_string | the reference string to the current value |
[in] | value | the value to consider |
[in,out] | result | the result object to insert values to |
- Note:
- Empty objects or arrays are flattened to `null`.
Definition at line 9196 of file json.hpp.
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
create and return a reference to the pointed to value
Definition at line 8828 of file json.hpp.
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
const_reference nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::get_checked |
( |
const_pointer |
ptr | ) |
const [inline, private] |
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
return a reference to the pointed to value
- Parameters:
-
- Returns:
- reference to the JSON value pointed to by the JSON pointer
Linear in the length of the JSON pointer.
- Exceptions:
-
std::out_of_range | if the JSON pointer can not be resolved |
std::domain_error | if an array index begins with '0' |
std::invalid_argument | if an array index was not a number |
Definition at line 8897 of file json.hpp.
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
return a const reference to the pointed to value
- Parameters:
-
- Returns:
- const reference to the JSON value pointed to by the JSON pointer
Definition at line 8993 of file json.hpp.
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
return whether pointer points to the root document
Definition at line 8808 of file json.hpp.
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::operator std::string |
( |
| ) |
const [inline] |
return a string representation of the JSON pointer
- Invariant:
- For each JSON pointer `ptr`, it holds:
- Returns:
- a string representation of the JSON pointer
{The example shows the result of `to_string`., json_pointer__to_string}
- Since:
- version 2.0.0
Definition at line 8788 of file json.hpp.
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
remove and return last reference pointer
Definition at line 8795 of file json.hpp.
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
static void nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::replace_substring |
( |
std::string & |
s, |
|
|
const std::string & |
f, |
|
|
const std::string & |
t |
|
) |
| [inline, static, private] |
replace all occurrences of a substring by another string
- Parameters:
-
[in,out] | s | the string to manipulate |
[in] | f | the substring to replace with t |
[out] | t | the string to replace f |
- Returns:
- The string s where all occurrences of f are replaced with t.
- Precondition:
- The search string f must not be empty.
- Since:
- version 2.0.0
Definition at line 9157 of file json.hpp.
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
static std::vector<std::string> nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::split |
( |
std::string |
reference_string | ) |
[inline, static, private] |
split the string input to reference tokens
Definition at line 9082 of file json.hpp.
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
return a string representation of the JSON pointer
- Invariant:
- For each JSON pointer `ptr`, it holds:
- Returns:
- a string representation of the JSON pointer
{The example shows the result of `to_string`., json_pointer__to_string}
- Since:
- version 2.0.0
Definition at line 8775 of file json.hpp.
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
static void nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::unescape |
( |
std::string & |
s | ) |
[inline, static, private] |
unescape tilde and slash
Definition at line 9181 of file json.hpp.
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
- Parameters:
-
- Returns:
- unflattened JSON
Definition at line 9254 of file json.hpp.
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>