mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-07 03:06:03 +08:00
getString("null")
This commit is contained in:
@@ -78,7 +78,7 @@ import java.util.Map;
|
|||||||
* </ul>
|
* </ul>
|
||||||
|
|
||||||
* @author JSON.org
|
* @author JSON.org
|
||||||
* @version 2010-12-24
|
* @version 2010-12-28
|
||||||
*/
|
*/
|
||||||
public class JSONArray {
|
public class JSONArray {
|
||||||
|
|
||||||
@@ -322,7 +322,8 @@ public class JSONArray {
|
|||||||
* @throws JSONException If there is no value for the index.
|
* @throws JSONException If there is no value for the index.
|
||||||
*/
|
*/
|
||||||
public String getString(int index) throws JSONException {
|
public String getString(int index) throws JSONException {
|
||||||
return get(index).toString();
|
Object object = get(index);
|
||||||
|
return object == JSONObject.NULL ? null : object.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -87,7 +87,7 @@ import java.util.TreeSet;
|
|||||||
* <li>Numbers may have the <code>0x-</code> <small>(hex)</small> prefix.</li>
|
* <li>Numbers may have the <code>0x-</code> <small>(hex)</small> prefix.</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* @author JSON.org
|
* @author JSON.org
|
||||||
* @version 2010-12-24
|
* @version 2010-12-28
|
||||||
*/
|
*/
|
||||||
public class JSONObject {
|
public class JSONObject {
|
||||||
|
|
||||||
@@ -627,7 +627,8 @@ public class JSONObject {
|
|||||||
* @throws JSONException if the key is not found.
|
* @throws JSONException if the key is not found.
|
||||||
*/
|
*/
|
||||||
public String getString(String key) throws JSONException {
|
public String getString(String key) throws JSONException {
|
||||||
return get(key).toString();
|
Object object = get(key);
|
||||||
|
return object == NULL ? null : object.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user