A library for Dart developers.

Usage

A simple usage example:

import 'package:json_serializable_dart/serializable_json.dart';

part 'json_seriazable_dart_example.g.dart';

void main() {
  final test = TestClass()..fromJson({'i': 1, 'm': 'ok'});
  final copy = TestClass()..copyFrom(test);
  copy.g = ["I\'copy"];
  print(test.toMap());
  print(copy.toMap());
}

@SerializableJson(methodOverlayName: 'Teradata', nullSafe: false)
class TestClass {
  int? i;
  late String m;
  List<String>? g;

  Map<String, dynamic> toMap() => _$TeradataToJson(this);

  void fromJson(Map<String, dynamic> json) {
    _$TeradataFromJson(this, json);
  }

  //for example copy instanse
  void copyFrom(TestClass from) {
    fromJson(from.toMap());
  }
}

Libraries

builder
generator
json_serializable_dart
serializable_json