パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.2.1

json_diff

2つのJSONオブジェクトを比較するためのユーティリティ

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
1.4万
いいね数
25
Pub ポイント
130

パッケージをインストール

flutter pub add json_diff

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

2つのJSONオブジェクトを比較し、詳細な差分を生成するためのユーティリティを提供するFlutter/Dartパッケージです。構造間の追加、削除、変更を特定し、JSONデータの変更を追跡するのに最適です。ネストされたオブジェクトと配列をサポートしており、開発者がプログラム的に違いを理解できるように、明確で構造的な出力を提供します。クロスプラットフォーム対応を想定して設計されており、Android、iOS、Web、macOS、Windows、Linuxでスムーズに動作します。軽量で、既存のDartプロジェクトへの統合も簡単です。

用途

  • API レスポンスの比較
  • 構成の変更を追跡する
  • JSON の更新のデバッグ
  • JSONデータのバージョニング
  • リアルタイムデータ同期
  • データ整合性の検証

主な機能

  • ネストされたオブジェクトの比較
  • 配列の差分検出
  • 差分出力形式のクリア
  • クロスプラットフォーム互換性
  • 軽量で高速
  • null 値およびプリミティブ値をサポートしています

適している対象

  • 動的JSONを使用する開発者
  • 変更追跡が必要なアプリ
  • データ検証用ツール
  • デバッグとテストワークフロー
  • リアルタイム共同作業機能

注意事項

  • 循環参照を処理できない可能性があります
  • 大きなJSONはパフォーマンスに影響を与える可能性があります
  • 出力形式の解析が必要です
  • diffロジックのカスタマイズが限定的
  • バイナリデータ用に設計されていません
  • 複雑な型の手動処理が必要

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Build Status

Generate a diff between two JSON strings.

Usage

Here's a basic example which features a deleted object, a new object, a changed object, and a deeply changed object:

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]}
print(diff.node);               // => a Map<String,DiffNode>
print(diff.node['d']);          // => a DiffNode
print(diff.node['d'].added);    // => {"z": 16}
print(diff.node['d'].removed);  // => {"y": 8}

So that's pretty fun. So when you diff two JSON strings, you get back a DiffNode. A DiffNode is a heirarchical structure that vaguely mirrors the structure of the input JSON strings. In this example, the top-level DiffNode we got back has

  • an added property, which is a Map of top-level properties that were not found in left, and were found in right.
  • a removed property, which is a Map of top-level properties that were found in left, but were not found in right.
  • a changed property, which is a Map of top-level properties whose values are different in left and in right. The values in this Map are two-element Arrays. The 0th element is the old value (from left), and the 1st element is the new value (from right).
  • a moved property, which is a Map of indexes, where key is the original index of an element, and value is index in the changed list.
  • a node property, a Map of the properties found in both left and right that have deep differences. The values of this Map are more DiffNodes.
  • a path property, which is a List of indexes, describing the path from the root where this DiffNode is operating.

Contributing

Contributions welcome! Please read the contribution guidelines.

Disclaimer

This is not an official Google product.

カテゴリー

依存関係

依存関係一覧 2 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。