Returns the JsonToken#BOOLEAN boolean value of the next token, consuming it. @throws IllegalStateException if the next token is not a boolean or if this reader is closed.
()
| 475 | * this reader is closed. |
| 476 | */ |
| 477 | public boolean nextBoolean() throws IOException { |
| 478 | quickPeek(); |
| 479 | if (value == null || token == JsonToken.STRING) { |
| 480 | throw new IllegalStateException("Expected a boolean but was " + peek()); |
| 481 | } |
| 482 | |
| 483 | boolean result; |
| 484 | if (value.equalsIgnoreCase("true")) { |
| 485 | result = true; |
| 486 | } else if (value.equalsIgnoreCase("false")) { |
| 487 | result = false; |
| 488 | } else { |
| 489 | throw new IllegalStateException("Not a boolean: " + value); |
| 490 | } |
| 491 | |
| 492 | advance(); |
| 493 | return result; |
| 494 | } |
| 495 | |
| 496 | /** |
| 497 | * Consumes the next token from the JSON stream and asserts that it is a |