Returns the JsonToken#NUMBER double value of the next token, consuming it. If the next token is a string, this method will attempt to parse it as a double. @throws IllegalStateException if the next token is not a literal value. @throws NumberFormatException if the next literal value cannot
()
| 523 | * as a double, or is non-finite. |
| 524 | */ |
| 525 | public double nextDouble() throws IOException { |
| 526 | quickPeek(); |
| 527 | if (value == null) { |
| 528 | throw new IllegalStateException("Expected a double but was " + peek()); |
| 529 | } |
| 530 | |
| 531 | double result = Double.parseDouble(value); |
| 532 | |
| 533 | if ((result >= 1.0d && value.startsWith("0"))) { |
| 534 | throw new NumberFormatException("JSON forbids octal prefixes: " + value); |
| 535 | } |
| 536 | |
| 537 | if (!lenient && (Double.isNaN(result) || Double.isInfinite(result))) { |
| 538 | throw new NumberFormatException("JSON forbids NaN and infinities: " + value); |
| 539 | } |
| 540 | |
| 541 | advance(); |
| 542 | return result; |
| 543 | } |
| 544 | |
| 545 | /** |
| 546 | * Returns the {@link JsonToken#NUMBER long} value of the next token, |