Bugfix json serialization
This commit is contained in:
parent
3f5d795e15
commit
6fb4de6752
|
@ -100,9 +100,9 @@ public abstract class Trigger {
|
||||||
static Trigger instantiate(JSONObject object) {
|
static Trigger instantiate(JSONObject object) {
|
||||||
try {
|
try {
|
||||||
String type = object.getString("type");
|
String type = object.getString("type");
|
||||||
String data = object.getString("data");
|
JSONObject data = object.getJSONObject("data");
|
||||||
Class clazz = Class.forName(type);
|
Class clazz = Class.forName(type);
|
||||||
return ((Trigger) clazz.newInstance()).fromJSON(data);
|
return ((Trigger) clazz.newInstance()).fromJSON(data.toString());
|
||||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | JSONException e) {
|
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class TriggerBg extends Trigger {
|
||||||
data.put("threshold", threshold);
|
data.put("threshold", threshold);
|
||||||
data.put("comparator", comparator.toString());
|
data.put("comparator", comparator.toString());
|
||||||
data.put("units", units);
|
data.put("units", units);
|
||||||
o.put("data", data.toString());
|
o.put("data", data);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,7 @@ public class TriggerTime extends Trigger {
|
||||||
data.put("minute", minute);
|
data.put("minute", minute);
|
||||||
data.put("validTo", validTo);
|
data.put("validTo", validTo);
|
||||||
object.put("type", TriggerTime.class.getName());
|
object.put("type", TriggerTime.class.getName());
|
||||||
object.put("data", data.toString());
|
object.put("data", data);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue