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
- Since
- version 2.0.0
Definition at line 10869 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::json_pointer |
( |
const std::string & |
s = "" | ) |
|
|
inlineexplicit |
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
-
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 10897 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>
escape tilde and slash
Definition at line 11340 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
-
[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 11364 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>
reference nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::get_and_create |
( |
reference |
j | ) |
const |
|
inlineprivate |
create and return a reference to the pointed to value
Linear in the number of reference tokens.
Definition at line 10969 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>
reference nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::get_checked |
( |
pointer |
ptr | ) |
const |
|
inlineprivate |
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>
reference nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::get_unchecked |
( |
pointer |
ptr | ) |
const |
|
inlineprivate |
return a reference to the pointed to value
- Note
- This version does not throw if a value is not present, but tries to create nested values instead. For instance, calling this function with pointer
"/this/that"
on a null value is equivalent to calling operator[]("this").operator[]("that")
on that value, effectively changing the null value to an object.
- 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 11044 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 11163 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>
bool nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::is_root |
( |
| ) |
const |
|
inlineprivate |
return whether pointer points to the root document
Definition at line 10947 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 10927 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>
std::string nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::pop_back |
( |
| ) |
|
|
inlineprivate |
remove and return last reference pointer
Definition at line 10934 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>
replace all occurrences of a substring by another string
- Parameters
-
[in,out] | s | the string to manipulate; changed so that all occurrences of f are replaced with t |
[in] | f | the substring to replace with t |
[in] | t | the string to replace f |
- Precondition
- The search string f must not be empty.
- Since
- version 2.0.0
Definition at line 11325 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 |
( |
const std::string & |
reference_string | ) |
|
|
inlinestaticprivate |
split the string input to reference tokens
Definition at line 11252 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>
std::string nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::to_string |
( |
| ) |
const |
|
inlinenoexcept |
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 10916 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>
json_pointer nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::top |
( |
| ) |
const |
|
inlineprivate |
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 | ) |
|
|
inlinestaticprivate |
unescape tilde and slash
Definition at line 11349 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 basic_json nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::unflatten |
( |
const basic_json & |
value | ) |
|
|
inlinestaticprivate |
- Parameters
-
- Returns
- unflattened JSON
Definition at line 11422 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>
std::vector<std::string> nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::reference_tokens {} |
|
private |