json_delta 0.1.0 copy "json_delta: ^0.1.0" to clipboard
json_delta: ^0.1.0 copied to clipboard

Dart extension for serializing and an object to a JSON delta.

Introducing a mixin class that implements a toJsonDelta() method that serializes the object to a JSON map of values of the changes in the object.

Usage #

final person = Person("John", "Doe", 30);
person.lastName = "Smith";
person.age = 31;
final delta = person.toJsonDelta(); // {"lastName": "Smith", "age": 31}

Implement in your models #

class Person extends JsonSerializable with JsonDelta {
  String firstName;
  String lastName;
  int age;

  Person({
    required this.firstName,
    required this.lastName,
    required this.age,
  }) {
    saveJsonDeltaState();
  }

  @override
  Map<String, dynamic> toJson() {
    return {
      'firstName': firstName,
      'lastName': lastName,
      'age': age,
    };
  }
}

Additional information #

This package is compatible with json_serializable which facilitates your generation of JSON.

3
likes
150
pub points
12%
popularity

Publisher

verified publisheroddbit.id

Dart extension for serializing and an object to a JSON delta.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

collection, flutter

More

Packages that depend on json_delta