blob: 0711b8d989319c281973babab89b903c86765994 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
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.trim()));
}
@Override
public String serialize2String(T target) {
JSONObject json = serialize2JSON(target);
String serialized = json.toString();
return serialized;
}
}
|