A test to ensure that null values override default values when nulls are present in input Json during deserialization.
This commit is contained in:
parent
1da3ef9891
commit
ae85e6cce6
@ -166,4 +166,15 @@ public class NullObjectAndFieldTest extends TestCase {
|
|||||||
return obj;
|
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 = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user