MQTTSuite
Loading...
Searching...
No Matches
nlohmann::json_patch Class Reference

#include <json-patch.hpp>

Collaboration diagram for nlohmann::json_patch:

Public Member Functions

 json_patch ()=default
 json_patch (json &&patch)
 json_patch (const json &patch)
json_patchadd (const json::json_pointer &, json value)
json_patchreplace (const json::json_pointer &, json value)
json_patchremove (const json::json_pointer &)
jsonget_json ()
const jsonget_json () const
 operator json () const

Static Private Member Functions

static void validateJsonPatch (json const &patch)

Private Attributes

json j_ = nlohmann::json::array()

Detailed Description

Definition at line 20 of file json-patch.hpp.

Constructor & Destructor Documentation

◆ json_patch() [1/3]

nlohmann::json_patch::json_patch ( )
default

◆ json_patch() [2/3]

nlohmann::json_patch::json_patch ( json && patch)

Definition at line 74 of file json-patch.cpp.

75 : j_(std::move(patch))
76{
78}
static void validateJsonPatch(json const &patch)

References j_, and validateJsonPatch().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ json_patch() [3/3]

nlohmann::json_patch::json_patch ( const json & patch)

Definition at line 80 of file json-patch.cpp.

81 : j_(std::move(patch))
82{
84}

References j_, and validateJsonPatch().

Here is the call graph for this function:

Member Function Documentation

◆ add()

json_patch & nlohmann::json_patch::add ( const json::json_pointer & ptr,
json value )

Definition at line 86 of file json-patch.cpp.

87{
88 j_.push_back(json{{"op", "add"}, {"path", ptr.to_string()}, {"value", std::move(value)}});
89 return *this;
90}
nlohmann::json json

References j_.

Referenced by anonymous_namespace{json-validator.cpp}::object::validate(), and anonymous_namespace{json-validator.cpp}::type_schema::validate().

Here is the caller graph for this function:

◆ get_json() [1/2]

json & nlohmann::json_patch::get_json ( )
inline

Definition at line 31 of file json-patch.hpp.

31{ return j_; }

References j_.

Referenced by anonymous_namespace{json-validator.cpp}::logical_combination< combine_logic >::validate().

Here is the caller graph for this function:

◆ get_json() [2/2]

const json & nlohmann::json_patch::get_json ( ) const
inline

Definition at line 32 of file json-patch.hpp.

32{ return j_; }

References j_.

◆ operator json()

nlohmann::json_patch::operator json ( ) const
inline

Definition at line 34 of file json-patch.hpp.

34{ return j_; }

References j_.

◆ remove()

json_patch & nlohmann::json_patch::remove ( const json::json_pointer & ptr)

Definition at line 98 of file json-patch.cpp.

99{
100 j_.push_back(json{{"op", "remove"}, {"path", ptr.to_string()}});
101 return *this;
102}

References j_.

◆ replace()

json_patch & nlohmann::json_patch::replace ( const json::json_pointer & ptr,
json value )

Definition at line 92 of file json-patch.cpp.

93{
94 j_.push_back(json{{"op", "replace"}, {"path", ptr.to_string()}, {"value", std::move(value)}});
95 return *this;
96}

References j_.

◆ validateJsonPatch()

void nlohmann::json_patch::validateJsonPatch ( json const & patch)
staticprivate

Definition at line 104 of file json-patch.cpp.

105{
106 // static put here to have it created at the first usage of validateJsonPatch
107 static nlohmann::json_schema::json_validator patch_validator(patch_schema);
108
109 patch_validator.validate(patch);
110
111 for (auto const &op : patch)
112 json::json_pointer(op["path"].get<std::string>());
113}

References nlohmann::json_schema::json_validator::json_validator(), anonymous_namespace{json-patch.cpp}::patch_schema, and nlohmann::json_schema::json_validator::validate().

Referenced by json_patch(), and json_patch().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ j_

json nlohmann::json_patch::j_ = nlohmann::json::array()
private

Definition at line 37 of file json-patch.hpp.

Referenced by add(), get_json(), get_json(), json_patch(), json_patch(), operator json(), remove(), and replace().


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