DiffNode class

A hierarchical structure representing the differences between two JSON objects.

A DiffNode object is returned by JsonDiffer's diff() method. DiffNode is a tree structure, referring to more DiffNodes in the node property. To access the differences in a DiffNode, refer to the following properties:

  • added is a Map of key-value pairs found in the right JSON but not in the left JSON.
  • removed is a Map of key-value pairs found in the left JSON but not in the right JSON.
  • changed is a Map referencing immediate values that are different between the left and right JSONs. Each key in the Map is a key whose values changed, mapping to a 2-element array which lists the left value and the right value.
  • node is a Map of deeper changes. Each key in this Map is a key whose values changed deeply between the left and right JSONs, mapping to a DiffNode containing those deep changes.

Constructors

DiffNode(List<Object> path)

Properties

added Map<Object, Object?>
A Map containing the key/value pairs that were added between the left JSON and the right.
final
changed Map<Object, List<Object?>>
A Map whose values are 2-element arrays containing the left value and the right value, corresponding to the mapping key.
final
hasAdded bool
no setter
hasChanged bool
no setter
hashCode int
The hash code for this object.
no setterinherited
hasMoved bool
no setter
hasNothing bool
no setter
hasRemoved bool
no setter
moved Map<int, int>
A Map of moved elements in the List, where the key is the original position, and the value is the new position.
final
node Map<Object, DiffNode>
A Map of deep changes between the two JSON objects.
final
path List<Object>
The path, starting from the root, where this DiffNode is describing the left and right JSON, e.g. "propertyA", 1, "propertyB".
final
removed Map<Object, Object?>
A Map containing the key/value pairs that were removed between the left JSON and the right.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

allAdded() Map<Object, Object?>?
containsKey(Object s) bool
A convenience method for node.containsKey().
forAllAdded(void ffn(Object? _, Object? o), {Map<Object, Object?> root = const {}}) → void
forEach(void ffn(Object s, DiffNode dn)) → void
forEachAdded(void ffn(Object s, Object? o)) → void
forEachChanged(void ffn(Object s, List<Object?> o)) → void
forEachOf(String key, void ffn(Object s, DiffNode dn)) → void
forEachRemoved(void ffn(Object s, Object? o)) → void
map(void ffn(Object s, DiffNode dn)) List<Object?>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
prune() → void
Prunes the DiffNode tree.
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](Object s) DiffNode?
A convenience method for node[].
operator []=(Object s, DiffNode d) → void
A convenience method for node[]=.