Skip to content
pubscout

json_patch

3.0.0, released 5 years ago by julien-scholz.dev

Pure Dart utility package for the JSON Patch standard to apply patches and perform diffs.

WASM-ready
$ flutter pub add json_patch
Source repository

What it does

Provides a diff algorithm to compare JSON-like objects and generates a list of patch operations. Also allows applying JSON Patch operations to a JSON-like Dart object.

AI-written summary of version 3.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to apply JSON Patch (RFC 6902) operations in Dart
  • You need to generate a diff between two JSON-like objects

Skip it when

  • You are looking for code generation of JSON parsing models

Strengths

  • Supports diff algorithm for JSON-like objects
  • Can apply JSON Patch operations with strict mode option
  • Pure Dart package

Weaknesses

  • Limited documentation beyond basic README and API docs

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
1

not documented

import 'package:json_patch/json_patch.dart';

final ops = JsonPatch.diff(oldJson, newJson);
try {
    final patchedJson = JsonPatch.apply(json, patches, strict: false);
} on JsonPatchTestFailedException catch (e) {
    print(e);
}

Alternatives

Packages that do the same job and could replace json_patch.

  • gtk

    GTK utilities for Flutter Linux applications, providing settings and application lifecycle helpers.

  • flutter_flavorizr

    A utility to easily create and configure application flavors in Flutter.

  • json_schema

    Validate JSON data against JSON Schema drafts in Dart.

  • cv

    Helpers to convert Dart objects to/from Map and JSON without code generation.