From 1bb48694f4fe9daff299d5c4a057dcb739b79575 Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Fri, 9 Sep 2011 08:10:21 +0000 Subject: [PATCH] Permit the null key, which is written as "null" --- .../gson/internal/bind/GsonCompatibleMapTypeAdapter.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gson/src/main/java/com/google/gson/internal/bind/GsonCompatibleMapTypeAdapter.java b/gson/src/main/java/com/google/gson/internal/bind/GsonCompatibleMapTypeAdapter.java index fd453b75..62e4ca29 100644 --- a/gson/src/main/java/com/google/gson/internal/bind/GsonCompatibleMapTypeAdapter.java +++ b/gson/src/main/java/com/google/gson/internal/bind/GsonCompatibleMapTypeAdapter.java @@ -96,7 +96,11 @@ public final class GsonCompatibleMapTypeAdapter extends TypeAdapter entry : map.entrySet()) { - writer.name(entry.getKey()); + String key = entry.getKey(); + if (key == null) { + key = "null"; + } + writer.name(key); valueTypeAdapter.write(writer, entry.getValue()); } writer.endObject();