code: public int nextInt() throws IOException {
      peek();
      if (token != JsonToken.STRING && token != JsonToken.NUMBER) {
        throw new IllegalStateException("Expected an int but was " + token
            + " at line " + getLineNumber() + " column " + getColumnNumber());
      }
  
      int result;
      try {
        result = Integer.parseInt(value);
      } catch (NumberFormatException ignored) {
        double asDouble = Double.parseDouble(value); // don't catch this NumberFormatException
        result = (int) asDouble;
        if (result != asDouble) {
          throw new NumberFormatException("Expected an int but was " + value
              + " at line " + getLineNumber() + " column " + getColumnNumber());
        }
      }
  
      if (result >= 1L && value.startsWith("0")) {
        throw new MalformedJsonException("JSON forbids octal prefixes: " + value
            + " at line " + getLineNumber() + " column " + getColumnNumber());
      }
  
      advance();
      return result;
    }
docs: Returns the {@link JsonToken#NUMBER int} value of the next token,
  consuming it. If the next token is a string, this method will attempt to
  parse it as an int. If the next token's numeric value cannot be exactly
  represented by a Java {@code int}, this method throws.
  
  @throws IllegalStateException if the next token is not a literal value.
  @throws NumberFormatException if the next literal value cannot be parsed
  as a number, or exactly represented as an int.