diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-15 22:55:09 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-15 22:55:09 +1200 |
commit | 946978e44223beb5b4b202c80dce6319f9a5cc14 (patch) | |
tree | f7f006121e3f4186dd0fbb3b9e8695cbd5826cf2 /src/org/traccar/http | |
parent | fd8ac5fd906b398f86ecd04820fedb86b8e39a9a (diff) | |
download | traccar-server-946978e44223beb5b4b202c80dce6319f9a5cc14.tar.gz traccar-server-946978e44223beb5b4b202c80dce6319f9a5cc14.tar.bz2 traccar-server-946978e44223beb5b4b202c80dce6319f9a5cc14.zip |
Store extra data in JSON format
Diffstat (limited to 'src/org/traccar/http')
-rw-r--r-- | src/org/traccar/http/JsonConverter.java | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/org/traccar/http/JsonConverter.java b/src/org/traccar/http/JsonConverter.java index d8773ec1f..deb676f6e 100644 --- a/src/org/traccar/http/JsonConverter.java +++ b/src/org/traccar/http/JsonConverter.java @@ -24,6 +24,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Collection; import java.util.Date; +import java.util.Map; import javax.json.Json; import javax.json.JsonArray; import javax.json.JsonArrayBuilder; @@ -31,6 +32,7 @@ import javax.json.JsonObject; import javax.json.JsonObjectBuilder; import javax.json.JsonValue; import org.traccar.model.Factory; +import org.traccar.model.MiscFormatter; public class JsonConverter { @@ -83,6 +85,8 @@ public class JsonConverter { method.invoke(object, dateFormat.parse(json.getString(name))); } else if (parameterType.isEnum()) { method.invoke(object, Enum.valueOf((Class<? extends Enum>) parameterType, json.getString(name))); + } else if (parameterType.equals(Map.class)) { + //method.invoke(object, json.getString(name)); } else { Object nestedObject = parameterType.newInstance(); populateObject(json.getJsonObject(name), nestedObject); @@ -126,6 +130,8 @@ public class JsonConverter { if (value != null) { json.add(name, dateFormat.format(value)); } + } else if (method.getReturnType().equals(Map.class)) { + json.add(name, MiscFormatter.toJson((Map) method.invoke(object))); } } catch (IllegalAccessException | InvocationTargetException error) { } |