Public Member Functions | Private Member Functions | Static Private Member Functions | Friends
nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer Class Reference

JSON Pointer. More...

#include <json.hpp>

List of all members.

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

Detailed Description

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.


Constructor & Destructor Documentation

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 = "") [inline, explicit]

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]sstring representing the JSON pointer; if omitted, the empty string is assumed which references the whole JSON value
Exceptions:
std::domain_errorif reference token is nonempty and does not begin with a slash (`/`); example: `"JSON pointer must be empty or begin with /"`
std::domain_errorif 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.


Member Function Documentation

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_stringthe reference string to the current value
[in]valuethe value to consider
[in,out]resultthe 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>
reference nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::get_and_create ( reference  j) const [inline, private]

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>
reference nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::get_checked ( pointer  ptr) const [inline, private]

Definition at line 8941 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>
const_reference nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::get_checked ( const_pointer  ptr) const [inline, private]

Definition at line 9037 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_unchecked ( pointer  ptr) const [inline, private]

return a reference to the pointed to value

Parameters:
[in]ptra JSON value
Returns:
reference to the JSON value pointed to by the JSON pointer

Linear in the length of the JSON pointer.

Exceptions:
std::out_of_rangeif the JSON pointer can not be resolved
std::domain_errorif an array index begins with '0'
std::invalid_argumentif 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>
const_reference nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::get_unchecked ( const_pointer  ptr) const [inline, private]

return a const reference to the pointed to value

Parameters:
[in]ptra JSON value
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>
bool nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::is_root ( ) const [inline, private]

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:
 {.cpp}
        ptr == json_pointer(ptr.to_string());
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>
std::string nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::pop_back ( ) [inline, private]

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]sthe string to manipulate
[in]fthe substring to replace with t
[out]tthe 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>
std::string nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::to_string ( ) const [inline]

return a string representation of the JSON pointer

Invariant:
For each JSON pointer `ptr`, it holds:
 {.cpp}
        ptr == json_pointer(ptr.to_string());
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>
json_pointer nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::top ( ) const [inline, private]

Definition at line 8813 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::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>
static basic_json nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::json_pointer::unflatten ( const basic_json value) [inline, static, private]
Parameters:
[in]valueflattened JSON
Returns:
unflattened JSON

Definition at line 9254 of file json.hpp.


Friends And Related Function Documentation

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>
friend class basic_json [friend]

allow basic_json to access private members

Definition at line 8731 of file json.hpp.


The documentation for this class was generated from the following file:


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:11