JSON for Modern C++ 3.9.1

__pad3__
accept
accept
accept
allocator_type
array
array_t
at
at
at
at
at
at
back
back
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
begin
begin
binary
binary
binary
binary
binary_t
boolean_t
cbegin
cbor_tag_handler_t
cend
clear
const_iterator
const_pointer
const_reference
const_reverse_iterator
contains
contains
count
crbegin
crend
detail::external_constructor
diff
difference_type
dump
emplace
emplace_back
empty
end
end
erase
erase
erase
erase
error_handler_t
exception
find
find
flatten
from_bson
from_bson
from_bson
from_bson
from_cbor
from_cbor
from_cbor
from_cbor
from_msgpack
from_msgpack
from_msgpack
from_msgpack
from_ubjson
from_ubjson
from_ubjson
from_ubjson
front
front
get
get
get
get
get
get
get_allocator
get_binary
get_binary
get_ptr
get_ptr
get_ref
get_ref
get_to
get_to
get_to
initializer_list_t
input_format_t
insert
insert
insert
insert
insert
insert
insert_iterator
invalid_iterator
is_array
is_binary
is_boolean
is_discarded
is_null
is_number
is_number_float
is_number_integer
is_number_unsigned
is_object
is_primitive
is_string
is_structured
items
items
iterator
iterator_wrapper
iterator_wrapper
json_pointer
json_sax_t
json_serializer
m_value
max_size
merge_patch
meta
number_float_t
number_integer_t
number_unsigned_t
object
object_comparator_t
object_t
operator value_t
operator ValueType
operator!=
operator!=
operator!=
operator+=
operator+=
operator+=
operator+=
operator<
operator<
operator<
operator<<
operator<<
operator<=
operator<=
operator<=
operator=
operator==
operator==
operator==
operator>
operator>
operator>
operator>=
operator>=
operator>=
operator>>
operator>>
operator[]
operator[]
operator[]
operator[]
operator[]
operator[]
operator[]
operator[]
other_error
out_of_range
parse
parse
parse
parse_error
parse_event_t
parser_callback_t
patch
pointer
push_back
push_back
push_back
push_back
rbegin
rbegin
reference
rend
rend
reverse_iterator
sax_parse
sax_parse
sax_parse
size
size_type
string_t
swap
swap
swap
swap
swap
swap
swap
to_bson
to_bson
to_bson
to_cbor
to_cbor
to_cbor
to_msgpack
to_msgpack
to_msgpack
to_ubjson
to_ubjson
to_ubjson
type
type_error
type_name
unflatten
update
update
value
value
value
value
value_t
value_type
~basic_json
| ## ◆ diff() 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< typename T, typename SFINAE=void > class JSONSerializer = adl_serializer, class BinaryType = std::vector<std::uint8_t>>
static basic_json nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType >::diff | ( | const basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType > & | source,
|  | const basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType > & | target,
|  | const std::string & | path = `""`
| ) |  |
| inline static
  Creates a JSON Patch so that value source can be changed into the value target by calling patch function. Invariant For two JSON values source and target, the following code yields always `true`: source.patch(diff(source, target)) == target; Note Currently, only `remove`, `add`, and `replace` operations are generated. Parameters
  [in] | source | JSON value to compare from
  [in] | target | JSON value to compare against
  [in] | path | helper value to create JSON pointers
  Returns a JSON patch to convert the source to target Complexity Linear in the lengths of source and target. Example The following code shows how a JSON patch is created as a diff for two JSON values. 1 #include <iostream> 2 #include <iomanip> 3 #include <nlohmann/json.hpp> 4 5 using json = nlohmann::json; 6 7 int main() 8 { 9 // the source document 10 json source = R"( 11 { 12 "baz": "qux", 13 "foo": "bar" 14 } 15 )"_json; 16 17 // the target document 18 json target = R"( 19 { 20 "baz": "boo", 21 "hello": [ 22 "world" 23 ] 24 } 25 )"_json; 26 27 // create the patch 28 json patch = json::diff(source, target); 29 30 // roundtrip 31 json patched_source = source.patch(patch); 32 33 // output patch and roundtrip result 34 std::cout << std::setw(4) << patch << "\n\n" 35 << std::setw(4) << patched_source << std::endl; 36 } Output (play with this example online):
      [
          {
              "op": "replace",
              "path": "/baz",
              "value": "boo"
          },
          {
              "op": "remove",
              "path": "/foo"
          },
          {
              "op": "add",
              "path": "/hello",
              "value": [
                  "world"
              ]
          }
      ]

      {
          "baz": "boo",
          "hello": [
              "world"
          ]
      }
  The example code above can be translated with
      g++ -std=c++11 -Isingle_include doc/examples/diff.cpp -o diff
See also patch – apply a JSON patch merge_patch – apply a JSON Merge Patch RFC 6902 (JSON Patch) Since version 2.0.0 Definition at line 24991 of file json.hpp.

nlohmann::basic_json::patch
basic_json patch(const basic_json &json_patch) const
applies a JSON patch
Definition: json.hpp:24695
nlohmann::basic_json::diff
static basic_json diff(const basic_json &source, const basic_json &target, const std::string &path="")
creates a diff as a JSON patch
Definition: json.hpp:24991
nlohmann::json
basic_json<> json
default JSON class
Definition: json.hpp:2940