quicktype
quicktype copied to clipboard
[Dart] JSON Serializable Option
Add JSON Serializable Option under Dart, adds the annotation and converts the json encoders/decoders to be handled by the package
import 'package:json_annotation/json_annotation.dart';
part 'example.g.dart';
@JsonSerializable(nullable: false)
class Person {
final String firstName;
final String lastName;
final DateTime dateOfBirth;
Person({this.firstName, this.lastName, this.dateOfBirth});
factory Person.fromJson(Map<String, dynamic> json) => _$PersonFromJson(json);
Map<String, dynamic> toJson() => _$PersonToJson(this);
}
https://deploy-preview-3--dart-quicktype.netlify.app/
https://github.com/chunlee-thong/dart-quicktype/pull/3
Add JSON Serializable Option under Dart, adds the annotation and converts the json encoders/decoders to be handled by the package
import 'package:json_annotation/json_annotation.dart'; part 'example.g.dart'; @JsonSerializable(nullable: false) class Person { final String firstName; final String lastName; final DateTime dateOfBirth; Person({this.firstName, this.lastName, this.dateOfBirth}); factory Person.fromJson(Map<String, dynamic> json) => _$PersonFromJson(json); Map<String, dynamic> toJson() => _$PersonToJson(this); }