quicktype icon indicating copy to clipboard operation
quicktype copied to clipboard

[Dart] JSON Serializable Option

Open jordanliu opened this issue 5 years ago • 1 comments

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);
}

jordanliu avatar Jan 04 '21 19:01 jordanliu

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);
}

sagarmahobia avatar Jun 25 '22 15:06 sagarmahobia