json_diff
0.2.1, released 4 years ago by an unverified publisher
Utilities for diffing two JSON objects in Dart.
What it does
Generates a hierarchical diff between two JSON structures. Returns added, removed, changed, moved entries and nested DiffNodes for deep differences.
AI-written summary of version 0.2.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to compare two JSON payloads to detect additions, deletions, or modifications.
- You want a simple, null‑safe API to produce a readable diff for configuration or API responses.
Skip it when
- You require streaming diff of very large JSON documents.
- You need a high‑performance binary diff or patch generation.
Strengths
- Clear, hierarchical DiffNode API
- Supports moved elements in lists
- Null‑safe and pure Dart
Weaknesses
- Operates only on in‑memory data
- No streaming or incremental diff support
- Small ecosystem and limited documentation
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
import 'package:json_diff/json_diff.dart';
final left = {"a": 2, "b": 3, "c": 5, "d": {"x": 4, "y": 8}};
final right = {"b": 7, "c": 5, "d": {"x": 4, "z": 16}, "e": 11};
final differ = JsonDiffer.fromJson(left, right);
DiffNode diff = differ.diff();
print(diff.added); // {"e": 11}
print(diff.removed); // {"a": 2}
print(diff.changed); // {"b": [3, 7]}
Alternatives
Packages that do the same job and could replace json_diff.
- gtk
GTK utilities for Flutter Linux applications, providing settings and application lifecycle helpers.
76Compare - dart_helper_utils
Dart extensions and helpers for maps, strings, collections, dates, async, and intl formatting.
80Compare - flutter_flavorizr
A utility to easily create and configure application flavors in Flutter.
86Compare - cv
Helpers to convert Dart objects to/from Map and JSON without code generation.
79Compare
Works with
Packages commonly used together with json_diff: ones it builds on, ones built on it, and its own family.