本文整理了Java中org.json.JSONArray.getNumber()
方法的一些代码示例,展示了JSONArray.getNumber()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONArray.getNumber()
方法的具体详情如下:
包路径:org.json.JSONArray
类名称:JSONArray
方法名:getNumber
[英]Get the Number value associated with a key.
[中]获取与键关联的数字值。
代码示例来源:origin: b3log/latke
/**
* Get the int 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 is not a number.
*/
public int getInt(int index) throws JSONException {
return this.getNumber(index).intValue();
}
代码示例来源:origin: b3log/latke
/**
* Get the double 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 number.
*/
public double getDouble(int index) throws JSONException {
return this.getNumber(index).doubleValue();
}
代码示例来源:origin: b3log/latke
/**
* Get the float value associated with a key.
*
* @param index
* The index must be between 0 and length() - 1.
* @return The numeric value.
* @throws JSONException
* if the key is not found or if the value is not a Number
* object and cannot be converted to a number.
*/
public float getFloat(int index) throws JSONException {
return this.getNumber(index).floatValue();
}
代码示例来源:origin: b3log/latke
/**
* Get the long 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 number.
*/
public long getLong(int index) throws JSONException {
return this.getNumber(index).longValue();
}
代码示例来源:origin: org.b3log/latke
/**
* Get the int 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 is not a number.
*/
public int getInt(int index) throws JSONException {
return this.getNumber(index).intValue();
}
代码示例来源:origin: org.b3log/latke
/**
* Get the float value associated with a key.
*
* @param index
* The index must be between 0 and length() - 1.
* @return The numeric value.
* @throws JSONException
* if the key is not found or if the value is not a Number
* object and cannot be converted to a number.
*/
public float getFloat(int index) throws JSONException {
return this.getNumber(index).floatValue();
}
代码示例来源:origin: org.b3log/latke
/**
* Get the double 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 number.
*/
public double getDouble(int index) throws JSONException {
return this.getNumber(index).doubleValue();
}
代码示例来源:origin: org.b3log/latke
/**
* Get the long 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 number.
*/
public long getLong(int index) throws JSONException {
return this.getNumber(index).longValue();
}
代码示例来源:origin: jnidzwetzki/bitfinex-v2-wss-api-java
private BitfinexOrderBookEntry jsonToRawOrderbookEntry(final JSONArray jsonArray) {
final long orderId = jsonArray.getNumber(0).longValue();
final BigDecimal price = jsonArray.getBigDecimal(1);
final BigDecimal amount = jsonArray.getBigDecimal(2);
return new BitfinexOrderBookEntry(orderId, price, amount, null);
}
代码示例来源:origin: jnidzwetzki/bitfinex-v2-wss-api-java
private BitfinexExecutedTrade jsonToExecutedTrade(final JSONArray jsonArray) {
final BitfinexExecutedTrade executedTrade = new BitfinexExecutedTrade();
final long id = jsonArray.getNumber(0).longValue();
executedTrade.setTradeId(id);
final long timestamp = jsonArray.getNumber(1).longValue();
executedTrade.setTimestamp(timestamp);
final BigDecimal amount = jsonArray.getBigDecimal(2);
executedTrade.setAmount(amount);
// Funding or Currency
if (jsonArray.optNumber(4) != null) {
final BigDecimal rate = jsonArray.getBigDecimal(3);
executedTrade.setRate(rate);
final Long period = jsonArray.getLong(4);
executedTrade.setPeriod(period);
} else {
final BigDecimal price = jsonArray.getBigDecimal(3);
executedTrade.setPrice(price);
}
return executedTrade;
}
内容来源于网络,如有侵权,请联系作者删除!