json 0.20.4 copy "json: ^0.20.4" to clipboard
json: ^0.20.4 copied to clipboard

Easy encoding and decoding of JSON maps (maps of type `Map<String, Object?>`). Uses a macro that auto-generates a `fromJson` decoding constructor and a `toJson` encoding method.

example/main.dart

import 'package:json/json.dart';

@JsonCodable()
class Point {
  int x = 0, y = 0;
}

@JsonCodable()
class ColoredPoint extends Point {
  String color = '';
}

main() {
  final json = {'x': 12, 'y': 42, 'color': '#2acaea'};
  var p = ColoredPoint.fromJson(json);

  p.x = 100;
  print('JSON ${p.toJson()}'); // Prints: JSON {x: 100, y: 42, color: #2acaea}
}
94
likes
150
points
1.53k
downloads

Publisher

verified publisherlabs.dart.dev

Weekly Downloads

Easy encoding and decoding of JSON maps (maps of type `Map<String, Object?>`). Uses a macro that auto-generates a `fromJson` decoding constructor and a `toJson` encoding method.

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

macros

More

Packages that depend on json