diff --git a/gson/src/main/java/com/google/gson/JsonPrimitive.java b/gson/src/main/java/com/google/gson/JsonPrimitive.java
index <HASH>..<HASH> 100644
--- a/gson/src/main/java/com/google/gson/JsonPrimitive.java
+++ b/gson/src/main/java/com/google/gson/JsonPrimitive.java
@@ -330,4 +330,21 @@ public final class JsonPrimitive extends JsonElement {
     }
     return false;
   }
+
+  @Override
+  public int hashCode() {
+    return (value == null) ? 31 : value.hashCode();
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj) return true;
+    if (obj == null) return false;
+    if (getClass() != obj.getClass()) return false;
+    JsonPrimitive other = (JsonPrimitive)obj;
+    if (value == null) {
+      if (other.value != null) return false;
+    } else if (!value.equals(other.value)) return false;
+    return true;
+  }  
 }
Implementing hashcode and equals for JsonPrimitives as value type equality.