javiercbk / json_to_dart

Library that generates dart classes from json strings
https://javiercbk.github.io/json_to_dart/
The Unlicense
1.33k stars 372 forks source link

Give Option to make Json Serializable #58

Open pratikbutani opened 3 years ago

pratikbutani commented 3 years ago

Greetings!

I have used this tool. It is very useful excepting some problems.

I am using json_serializable library for JSON Parsing. It is creating toJson and fromJson method itself, we just need to write their format.

Example :

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

Hope for best if you can also support this thing.

sagarmahobia commented 2 years ago

https://deploy-preview-3--dart-quicktype.netlify.app/

check out and drop a comment at https://github.com/chunlee-thong/dart-quicktype/pull/3 and help it get merged by the author.