File tree 2 files changed +10
-1
lines changed
main/java/com/fasterxml/jackson/databind/node
test/java/com/fasterxml/jackson/databind/node
2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -177,9 +177,13 @@ public String asText(String defaultValue) {
177
177
@ Override
178
178
public boolean asBoolean (boolean defaultValue ) {
179
179
if (_value != null ) {
180
- if ("true" .equals (_value .trim ())) {
180
+ String v = _value .trim ();
181
+ if ("true" .equals (v )) {
181
182
return true ;
182
183
}
184
+ if ("false" .equals (v )) {
185
+ return false ;
186
+ }
183
187
}
184
188
return defaultValue ;
185
189
}
Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ public void testText()
31
31
32
32
assertEquals ("foobar" , n .asText ("barf" ));
33
33
assertEquals ("" , empty .asText ("xyz" ));
34
+
35
+ assertTrue (TextNode .valueOf ("true" ).asBoolean (true ));
36
+ assertTrue (TextNode .valueOf ("true" ).asBoolean (false ));
37
+ assertFalse (TextNode .valueOf ("false" ).asBoolean (true ));
38
+ assertFalse (TextNode .valueOf ("false" ).asBoolean (false ));
34
39
}
35
40
36
41
public void testBoolean ()
You can’t perform that action at this time.
0 commit comments