Boolean Type: Support also cases when a number/string value are passed, closes #33.

This commit is contained in:
kimchy 2010-02-20 01:50:50 +02:00
parent e6b5ec7aaa
commit 4806df426a
1 changed files with 12 additions and 0 deletions

View File

@ -124,6 +124,18 @@ public class JsonBooleanFieldMapper extends JsonFieldMapper<Boolean> {
if (nullValue != null) {
value = nullValue ? "T" : "F";
}
} else if (token == JsonToken.VALUE_NUMBER_INT) {
if (jsonContext.jp().getIntValue() == 0) {
value = "F";
} else {
value = "T";
}
} else if (token == JsonToken.VALUE_STRING) {
if (jsonContext.jp().getText().equals("false")) {
value = "F";
} else {
value = "T";
}
} else {
return null;
}