Implemented suggestions from code review r432 by adding a JsonNull for primitives if the value is null.

This commit is contained in:
Inderjeet Singh 2009-10-01 22:15:53 +00:00
parent c64b79c0f9
commit 1dcdd3fb3f

View File

@ -135,10 +135,8 @@ final class JsonSerializationVisitor implements ObjectNavigator.Visitor {
}
public void visitPrimitive(Object obj) {
if (obj != null) {
JsonElement json = new JsonPrimitive(obj);
assignToRoot(json);
}
JsonElement json = obj == null ? JsonNull.createJsonNull() : new JsonPrimitive(obj);
assignToRoot(json);
}
private void addAsChildOfObject(Field f, Type fieldType, Object fieldValue) {