From e345feb438e899736162463263addd3c8628a9f0 Mon Sep 17 00:00:00 2001 From: Joel Leitch Date: Thu, 14 Apr 2011 18:54:09 +0000 Subject: [PATCH] Comments from r821 --- gson/src/main/java/com/google/gson/JsonPrimitive.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gson/src/main/java/com/google/gson/JsonPrimitive.java b/gson/src/main/java/com/google/gson/JsonPrimitive.java index f9bce4b4..365f7bf8 100644 --- a/gson/src/main/java/com/google/gson/JsonPrimitive.java +++ b/gson/src/main/java/com/google/gson/JsonPrimitive.java @@ -129,6 +129,9 @@ public final class JsonPrimitive extends JsonElement { if (isBoolean()) { return getAsBooleanWrapper().booleanValue(); } else { + // Check to see if the value (as a String) is either "true" (ignore case) or "1". + // If so then we will assume that it is true; otherwise, false. + // The "1" case is for parsing JSON that assume bits as booleans (i.e. 0 and 1). String stringValue = getAsString(); return Boolean.parseBoolean(stringValue) || "1".equals(stringValue); }