aboutsummaryrefslogtreecommitdiff
path: root/src/com/juick/json/Place.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/juick/json/Place.java')
-rw-r--r--src/com/juick/json/Place.java28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/com/juick/json/Place.java b/src/com/juick/json/Place.java
index 63a5929c..4e3e5579 100644
--- a/src/com/juick/json/Place.java
+++ b/src/com/juick/json/Place.java
@@ -25,10 +25,10 @@ import org.json.JSONObject;
*
* @author Ugnich Anton
*/
-public class Place extends com.juick.Place {
+public class Place {
- public static Place parseJSON(JSONObject json) throws JSONException {
- Place jplace = new Place();
+ public static com.juick.Place parseJSON(JSONObject json) throws JSONException {
+ com.juick.Place jplace = new com.juick.Place();
jplace.pid = json.getInt("pid");
jplace.lat = json.getDouble("lat");
@@ -55,4 +55,26 @@ public class Place extends com.juick.Place {
return jplace;
}
+
+ public static JSONObject toJSON(com.juick.Place place) {
+ JSONObject json = new JSONObject();
+
+ try {
+ if (place.pid > 0) {
+ json.put("pid", place.pid);
+ }
+ if (place.lat >= -90 && place.lat <= 90) {
+ json.put("lat", place.lat);
+ }
+ if (place.lon >= -180 && place.lon <= 180) {
+ json.put("lon", place.lon);
+ }
+ if (place.name != null) {
+ json.put("name", place.name);
+ }
+ } catch (JSONException e) {
+ }
+
+ return json;
+ }
}