Skip to content

Commit d437cec

Browse files
committed
Merge branch 'master' of git://github.com/douglascrockford/JSON-java
Conflicts: JSONObject.java
2 parents f177889 + 449641a commit d437cec

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

‎JSONArray.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ of this software and associated documentation files (the "Software"), to deal
7878
* </ul>
7979
8080
* @author JSON.org
81-
* @version 2010-12-24
81+
* @version 2010-12-28
8282
*/
8383
public class JSONArray {
8484

@@ -322,7 +322,8 @@ public long getLong(int index) throws JSONException {
322322
* @throws JSONException If there is no value for the index.
323323
*/
324324
public String getString(int index) throws JSONException {
325-
return get(index).toString();
325+
Object object = get(index);
326+
return object == JSONObject.NULL ? null : object.toString();
326327
}
327328

328329

‎JSONObject.java‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ of this software and associated documentation files (the "Software"), to deal
8787
* <li>Numbers may have the <code>0x-</code> <small>(hex)</small> prefix.</li>
8888
* </ul>
8989
* @author JSON.org
90-
* @version 2010-12-24
90+
* @version 2010-12-28
9191
*/
9292
public class JSONObject {
9393

@@ -627,10 +627,8 @@ public static String[] getNames(Object object) {
627627
* @throws JSONException if the key is not found.
628628
*/
629629
public String getString(String key) throws JSONException {
630-
if(isNull(key)){
631-
return null;
632-
}
633-
return get(key).toString();
630+
Object object = get(key);
631+
return object == NULL ? null : object.toString();
634632
}
635633

636634

0 commit comments

Comments
 (0)