diff --git a/JSONArray.java b/JSONArray.java index 5d8841f..d3499e0 100755 --- a/JSONArray.java +++ b/JSONArray.java @@ -78,7 +78,7 @@ import java.util.Map; * * @author JSON.org - * @version 2010-12-24 + * @version 2010-12-28 */ public class JSONArray { @@ -322,7 +322,8 @@ public class JSONArray { * @throws JSONException If there is no value for the index. */ public String getString(int index) throws JSONException { - return get(index).toString(); + Object object = get(index); + return object == JSONObject.NULL ? null : object.toString(); } diff --git a/JSONObject.java b/JSONObject.java index 0c57050..486c797 100755 --- a/JSONObject.java +++ b/JSONObject.java @@ -87,7 +87,7 @@ import java.util.TreeSet; *
  • Numbers may have the 0x- (hex) prefix.
  • * * @author JSON.org - * @version 2010-12-24 + * @version 2010-12-28 */ public class JSONObject { @@ -627,7 +627,8 @@ public class JSONObject { * @throws JSONException if the key is not found. */ public String getString(String key) throws JSONException { - return get(key).toString(); + Object object = get(key); + return object == NULL ? null : object.toString(); }