From ad7da43a3969b8407c46c2fd5cba246ca9313fd8 Mon Sep 17 00:00:00 2001 From: zontreck Date: Fri, 12 Jul 2024 21:21:02 -0700 Subject: [PATCH] Adds a json serializable abstract class --- lib/structs/JsonSerializable.dart | 21 +++++++++++++++++++++ pubspec.yaml | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 lib/structs/JsonSerializable.dart diff --git a/lib/structs/JsonSerializable.dart b/lib/structs/JsonSerializable.dart new file mode 100644 index 0000000..3f6bc30 --- /dev/null +++ b/lib/structs/JsonSerializable.dart @@ -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 toJson(); + + /// Decodes json and returns the instance + static IJsonSerializable fromJson(String js) { + throw UnimplementedError(); + } + + /// Decodes json object + static IJsonSerializable decode(Map js) { + throw UnimplementedError(); + } +} \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 7b449b4..1d8c43c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: libac_dart description: "Aria's Creations code library" -version: 1.2.071124+1630 +version: 1.2.071224+2114 homepage: "https://zontreck.com"