Permalink
Browse files

bleurgh

  • Loading branch information...
1 parent fb11a84 commit e1fc90c0a8224361083c962c52ac8d3b28f9fdb7 @winterstein committed Apr 3, 2012
Showing with 25 additions and 7 deletions.
  1. +2 −1 changelist.txt
  2. +12 −6 src/winterwell/json/JSONObject.java
  3. +11 −0 src/winterwell/json/package-info.java
View
3 changelist.txt
@@ -4,7 +4,8 @@
- *Breaking Change*: LatLong is replaced by Location from jgeoplanet (a sister-project by Winterwell).
- New interfaces for geo-location: IPlace & IGeoCode
- Some JGeoPlanet classes moved into JTwitter so we still have no dependencies beyond Signpost.
-
+ - Minor improvements to JSONObject (error messages, map access)
+
2.5:
- Added getScreenNameIfKnown()
- Added sketch code for image uploading (not ready for use yet!).
View
18 src/winterwell/json/JSONObject.java
@@ -329,7 +329,7 @@ public JSONObject append(String key, Object value)
put(key, ((JSONArray)o).put(value));
} else {
throw new JSONException("JSONObject[" + key +
- "] is not a JSONArray.");
+ "] is not a JSONArray. "+o.getClass());
}
return this;
}
@@ -398,7 +398,7 @@ public boolean getBoolean(String key) throws JSONException {
return true;
}
throw new JSONException("JSONObject[" + quote(key) +
- "] is not a Boolean.");
+ "] is not a Boolean. "+o.getClass());
}
@@ -417,7 +417,7 @@ public double getDouble(String key) throws JSONException {
Double.valueOf((String)o).doubleValue();
} catch (Exception e) {
throw new JSONException("JSONObject[" + quote(key) +
- "] is not a number.");
+ "] is not a number. "+o.getClass());
}
}
@@ -452,7 +452,7 @@ public JSONArray getJSONArray(String key) throws JSONException {
return (JSONArray)o;
}
throw new JSONException("JSONObject[" + quote(key) +
- "] is not a JSONArray.");
+ "] is not a JSONArray. "+o.getClass());
}
@@ -470,7 +470,7 @@ public JSONObject getJSONObject(String key) throws JSONException {
return (JSONObject)o;
}
throw new JSONException("JSONObject[" + quote(key) +
- "] is not a JSONObject.");
+ "] is not a JSONObject. "+o.getClass());
}
@@ -774,7 +774,7 @@ public long optLong(String key, long defaultValue) {
/**
* Get an optional string associated with a key.
* It returns an empty string if there is no such key. If the value is not
- * a string and is not null, then it is coverted to a string.
+ * a string and is not null, then it is converted to a string.
*
* @param key A key string.
* @return A string which is the value.
@@ -783,6 +783,12 @@ public String optString(String key) {
return optString(key, "");
}
+ /**
+ * @return access to the underlying map (which has a better interface).
+ */
+ public Map<String,?> getMap() {
+ return myHashMap;
+ }
/**
* Get an optional string associated with a key.
View
11 src/winterwell/json/package-info.java
@@ -0,0 +1,11 @@
+
+/**
+ * This is a fork of org.json's JSON library. It makes a few improvements:
+ * <ul>
+ * <li>Provide access to standard Java List & Map interfaces.</li>
+ * <li>Error messages are a bit more helpful.</li>
+ * <li>Exceptions are runtime exceptions.</li>
+ * </ul>
+ * The package name has been changed to avoid collisions.
+ */
+package winterwell.json;

0 comments on commit e1fc90c

Please sign in to comment.