@Override
    public long longValue() {
      try {
        return Long.parseLong(value);
      } catch (NumberFormatException e) {
        return new BigDecimal(value).longValue();
      }
    }
This is a modified copy of Gson's internal LazilyParsedNumber.
java_src/src/main/java/com/google/crypto/tink/internal/JsonParser.java