aboutsummaryrefslogtreecommitdiff
path: root/src/com/juick/json/Place.java
diff options
context:
space:
mode:
authorGravatar Ugnich Anton2012-01-22 23:01:24 +0700
committerGravatar Ugnich Anton2012-01-22 23:01:24 +0700
commitcbcc5a5e4c1edd4689c756a2548a5087201ee74e (patch)
treea6b0d603af873ba3de7830121c3aedaa99f3f6c1 /src/com/juick/json/Place.java
parentbd7cfe95f4d15719f31e17d9aee6830066644948 (diff)
toJSON()
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;
+ }
}