json_delta_tool 1.0.0 copy "json_delta_tool: ^1.0.0" to clipboard
json_delta_tool: ^1.0.0 copied to clipboard

A simple tool for calculating the delta (difference) between 2 json objects with the same schema.

A simple tool for calculating the delta (difference) between 2 json objects with the same schema.

Particulary useful for editing objects in UI - enabling save button if the edited object differs from the original, and sending a PATCH request to the backend using the delta method.

Features #

This tool includes 2 basic functionalities:

  1. Check if 2 json objects differ
  2. Subtract 2 json objects and get a json object with the difference.

Getting started #

flutter pub install json_delta

Usage #

  Map<String, dynamic> person = {
    'name': 'John Doe',
    'age': 30,
    'email': 'example@mail.com'
  };

  Map<String, dynamic> editedPerson = {
    'name': 'John Doe',
    'age': 30,
    'email': 'newEmail@mail.com'
  };

  // Output: true
  print(JsonDelta.hasDelta(person, editedPerson));

  // Output: {'email': 'newEmail@mail.com'}
  print(JsonDelta.delta(person, editedPerson));

Additional information #

This tool is intended for work with objects of the same schema. For more detailed use cases see the examples.

Feel free to open issues in the GitHub repository.

2
likes
150
points
21
downloads

Publisher

unverified uploader

Weekly Downloads

A simple tool for calculating the delta (difference) between 2 json objects with the same schema.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

json_patch

More

Packages that depend on json_delta_tool