Skip to content

Commit 0eff50f

Browse files
committed
Check for JSONObject.NULL before casting to String [Fixes #209]
1 parent 3cc9570 commit 0eff50f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Parse/src/main/java/com/parse/ParseDecoder.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ public Object decode(Object object) {
7171
return convertJSONArrayToList((JSONArray) object);
7272
}
7373

74+
if (object == JSONObject.NULL) {
75+
return null;
76+
}
77+
7478
if (!(object instanceof JSONObject)) {
7579
return object;
7680
}

Parse/src/test/java/com/parse/ParseDecoderTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ public void testNonJSONObject() {
7373
assertSame(obj, ParseDecoder.get().decode(obj));
7474
}
7575

76+
@Test
77+
public void testNull() {
78+
Object object = ParseDecoder.get().decode(JSONObject.NULL);
79+
assertNull(object);
80+
}
81+
7682
@Test
7783
public void testParseFieldOperations() throws JSONException {
7884
JSONObject json = new JSONObject();

0 commit comments

Comments
 (0)