File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -531,6 +531,44 @@ public int optInt(int index, int defaultValue) {
531
531
}
532
532
}
533
533
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
+
534
572
/**
535
573
* Get the optional JSONArray associated with an index.
536
574
*
You can’t perform that action at this time.
0 commit comments