Adds a json serializable abstract class
This commit is contained in:
parent
5e6e47bd0a
commit
ad7da43a39
2 changed files with 22 additions and 1 deletions
21
lib/structs/JsonSerializable.dart
Normal file
21
lib/structs/JsonSerializable.dart
Normal file
|
@ -0,0 +1,21 @@
|
|||
import 'dart:convert';
|
||||
|
||||
abstract class IJsonSerializable {
|
||||
/// Encode json and return as String
|
||||
String encode() {
|
||||
return json.encode(toJson());
|
||||
}
|
||||
|
||||
/// Returns a Json Object
|
||||
Map<String,dynamic> toJson();
|
||||
|
||||
/// Decodes json and returns the instance
|
||||
static IJsonSerializable fromJson(String js) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
/// Decodes json object
|
||||
static IJsonSerializable decode(Map<String,dynamic> js) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue