Bugfix json serialization

This commit is contained in:
Nico Schmitz 2018-10-16 01:49:11 +02:00
parent 3f5d795e15
commit 6fb4de6752
3 changed files with 4 additions and 4 deletions

View file

@ -100,9 +100,9 @@ public abstract class Trigger {
static Trigger instantiate(JSONObject object) {
try {
String type = object.getString("type");
String data = object.getString("data");
JSONObject data = object.getJSONObject("data");
Class clazz = Class.forName(type);
return ((Trigger) clazz.newInstance()).fromJSON(data);
return ((Trigger) clazz.newInstance()).fromJSON(data.toString());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | JSONException e) {
e.printStackTrace();
}

View file

@ -66,7 +66,7 @@ public class TriggerBg extends Trigger {
data.put("threshold", threshold);
data.put("comparator", comparator.toString());
data.put("units", units);
o.put("data", data.toString());
o.put("data", data);
} catch (JSONException e) {
e.printStackTrace();
}

View file

@ -156,7 +156,7 @@ public class TriggerTime extends Trigger {
data.put("minute", minute);
data.put("validTo", validTo);
object.put("type", TriggerTime.class.getName());
object.put("data", data.toString());
object.put("data", data);
} catch (JSONException e) {
e.printStackTrace();
}