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,11 +135,9 @@ final class JsonSerializationVisitor implements ObjectNavigator.Visitor {
} }
public void visitPrimitive(Object obj) { public void visitPrimitive(Object obj) {
if (obj != null) { JsonElement json = obj == null ? JsonNull.createJsonNull() : new JsonPrimitive(obj);
JsonElement json = new JsonPrimitive(obj);
assignToRoot(json); assignToRoot(json);
} }
}
private void addAsChildOfObject(Field f, Type fieldType, Object fieldValue) { private void addAsChildOfObject(Field f, Type fieldType, Object fieldValue) {
JsonElement childElement = getJsonElementForChild(fieldType, fieldValue); JsonElement childElement = getJsonElementForChild(fieldType, fieldValue);