summaryrefslogtreecommitdiffstats
path: root/logo/src/xlogo/storage/JSONSerializer.java
diff options
context:
space:
mode:
authorMarko Živković <[email protected]>2015-02-25 22:30:45 +0000
committerMarko Živković <[email protected]>2015-02-25 22:30:45 +0000
commit43bec1cad4d8ed554484e8c6795cf07601c12074 (patch)
tree892d5d6512063b0645b53d751a2842bcc11e16f4 /logo/src/xlogo/storage/JSONSerializer.java
parentdb29411bc625a7527fef9c70f5e1aaa03142450f (diff)
Major refactoring of everything related to configuration files, especially the way of storing files.
git-svn-id: https://svn.code.sf.net/p/xlogo4schools/svn/trunk@24 3b0d7934-f7ef-4143-9606-b51f2e2281fd
Diffstat (limited to 'logo/src/xlogo/storage/JSONSerializer.java')
-rw-r--r--logo/src/xlogo/storage/JSONSerializer.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/logo/src/xlogo/storage/JSONSerializer.java b/logo/src/xlogo/storage/JSONSerializer.java
new file mode 100644
index 0000000..2766da4
--- /dev/null
+++ b/logo/src/xlogo/storage/JSONSerializer.java
@@ -0,0 +1,21 @@
+package xlogo.storage;
+
+import org.json.JSONObject;
+
+import xlogo.storage.workspace.Serializer;
+
+public abstract class JSONSerializer<T> implements Serializer<T>{
+ public abstract JSONObject serialize2JSON(T object);
+
+ public abstract T deserialize(JSONObject json);
+
+ @Override
+ public T deserialize(String json) {
+ return deserialize(new JSONObject(json));
+ }
+
+ @Override
+ public String serialize2String(T target) {
+ return serialize2JSON(target).toString();
+ }
+}