nlohmann::basic_json::diff

creates a diff as a JSON patch

Synopsis

Declared in <nlohmann/json.hpp>

[[nodiscard]]
static
basic_json
diff(
    basic_json const& source,
    basic_json const& target,
    string_t const& path = "");

Return Value

a JSON Patch (RFC 6902) document describing the changes needed to turn source into target

NOTE

The return value should not be discarded.

Parameters

NameDescription
sourceJSON value to compare from
targetJSON value to compare against
pathJSON Pointer path prefixed to the paths of the generated operations