File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -531,6 +531,44 @@ public int optInt(int index, int defaultValue) {
531531 }
532532 }
533533
534+ /**
535+ * Get the optional BigInteger value associated with an index. The
536+ * defaultValue is returned if there is no value for the index, or if the
537+ * value is not a number and cannot be converted to a number.
538+ *
539+ * @param index
540+ * The index must be between 0 and length() - 1.
541+ * @param defaultValue
542+ * The default value.
543+ * @return The value.
544+ */
545+ public BigInteger optBigInteger (int index , BigInteger defaultValue ) {
546+ try {
547+ return this .getBigInteger (index );
548+ } catch (Exception e ) {
549+ return defaultValue ;
550+ }
551+ }
552+
553+ /**
554+ * Get the optional BigDecimal value associated with an index. The
555+ * defaultValue is returned if there is no value for the index, or if the
556+ * value is not a number and cannot be converted to a number.
557+ *
558+ * @param index
559+ * The index must be between 0 and length() - 1.
560+ * @param defaultValue
561+ * The default value.
562+ * @return The value.
563+ */
564+ public BigDecimal optBigDecimal (int index , BigDecimal defaultValue ) {
565+ try {
566+ return this .getBigDecimal (index );
567+ } catch (Exception e ) {
568+ return defaultValue ;
569+ }
570+ }
571+
534572 /**
535573 * Get the optional JSONArray associated with an index.
536574 *
You can’t perform that action at this time.
0 commit comments