mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
latest
This commit is contained in:
parent
03c4fc72ba
commit
6ab6f063c8
2 changed files with 43 additions and 2 deletions
|
@ -28,6 +28,7 @@ import java.io.IOException;
|
|||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.Array;
|
||||
import java.math.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
@ -75,7 +76,7 @@ import java.util.Map;
|
|||
* </ul>
|
||||
*
|
||||
* @author JSON.org
|
||||
* @version 2015-06-04
|
||||
* @version 2015-07-04
|
||||
*/
|
||||
public class JSONArray implements Iterable<Object> {
|
||||
|
||||
|
@ -246,6 +247,46 @@ public class JSONArray implements Iterable<Object> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the BigDecimal value associated with an index.
|
||||
*
|
||||
* @param index
|
||||
* The index must be between 0 and length() - 1.
|
||||
* @return The value.
|
||||
* @throws JSONException
|
||||
* If the key is not found or if the value cannot be converted
|
||||
* to a BigDecimal.
|
||||
*/
|
||||
public BigDecimal getBigDecimal (int index) throws JSONException {
|
||||
Object object = this.get(index);
|
||||
try {
|
||||
return new BigDecimal(object.toString());
|
||||
} catch (Exception e) {
|
||||
throw new JSONException("JSONArray[" + index +
|
||||
"] could not convert to BigDecimal.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the BigInteger value associated with an index.
|
||||
*
|
||||
* @param index
|
||||
* The index must be between 0 and length() - 1.
|
||||
* @return The value.
|
||||
* @throws JSONException
|
||||
* If the key is not found or if the value cannot be converted
|
||||
* to a BigInteger.
|
||||
*/
|
||||
public BigInteger getBigInteger (int index) throws JSONException {
|
||||
Object object = this.get(index);
|
||||
try {
|
||||
return new BigInteger(object.toString());
|
||||
} catch (Exception e) {
|
||||
throw new JSONException("JSONArray[" + index +
|
||||
"] could not convert to BigInteger.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the int value associated with an index.
|
||||
*
|
||||
|
|
|
@ -92,7 +92,7 @@ import java.util.Set;
|
|||
* </ul>
|
||||
*
|
||||
* @author JSON.org
|
||||
* @version 2015-06-20
|
||||
* @version 2015-07-04
|
||||
*/
|
||||
public class JSONObject {
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue