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