hiranthaR / Json-to-Dart-Model

Json to Dart Model extension can convert JSON objects into Dart data classes. It supports pure Dart class conversion, Flutter-recommended JSON serialization using annotations, Freezed support, Effective Dart:Style, and many more features. Currently, it has more than 135,000 installs.
https://marketplace.visualstudio.com/items?itemName=hirantha.json-to-dart
MIT License
93 stars 17 forks source link

Added annotations support #34

Closed iamarnas closed 3 years ago

iamarnas commented 3 years ago

It is possible to mark JSON values as default or required. Everything that do you need to do, just add to your JSON key d@ or r@ and Json to Dart Model will generate them for you. More...

{
  "r@id": 1,
  "d@title": "Json To Dart Model"
}

Result

class Example {
  int id;
  String title;

  Example({@required this.id, this.title = 'Json To Dart Model'});
}