A test to ensure that null values override default values when nulls are present in input Json during deserialization.

This commit is contained in:
Inderjeet Singh 2009-10-06 01:55:44 +00:00
parent 1da3ef9891
commit ae85e6cce6

View File

@ -166,4 +166,15 @@ public class NullObjectAndFieldTest extends TestCase {
return obj;
}
}
public void testExplicitNullSetsFieldToNullDuringDeserialization() {
Gson gson = new Gson();
String json = "{value:null}";
ObjectWithField obj = gson.fromJson(json, ObjectWithField.class);
assertNull(obj.value);
}
private static class ObjectWithField {
String value = "";
}
}