Last updated:
0 purchases
json serializable dart
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());
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.