docs: public long nextLong() throws IOException {
      int p = peeked;
      if (p == PEEKED_NONE) {
        p = doPeek();
      }
  
      if (p == PEEKED_LONG) {
        peeked = PEEKED_NONE;
        pathIndices[stackSize - 1]++;
        return peekedLong;
      }
  
      if (p == PEEKED_NUMBER) {
        peekedString = new String(buffer, pos, peekedNumberLength);
        pos += peekedNumberLength;
      } else if (p == PEEKED_SINGLE_QUOTED || p == PEEKED_DOUBLE_QUOTED) {
        peekedString = nextQuotedValue(p == PEEKED_SINGLE_QUOTED ? '\'' : '"');
        try {
          long result = Long.parseLong(peekedString);
          peeked = PEEKED_NONE;
          pathIndices[stackSize - 1]++;
          return result;
        } catch (NumberFormatException ignored) {
          // Fall back to parse as a double below.
        }
      } else {
        throw new IllegalStateException("Expected a long but was " + peek()
            + " at line " + getLineNumber() + " column " + getColumnNumber() + " path " + getPath());
      }
  
      peeked = PEEKED_BUFFERED;
      double asDouble = Double.parseDouble(peekedString); // don't catch this NumberFormatException.
      long result = (long) asDouble;
      if (result != asDouble) { // Make sure no precision was lost casting to 'long'.
        throw new NumberFormatException("Expected a long but was " + peekedString
            + " at line " + getLineNumber() + " column " + getColumnNumber() + " path " + getPath());
      }
      peekedString = null;
      peeked = PEEKED_NONE;
      pathIndices[stackSize - 1]++;
      return result;
    }