本文整理匯總了Java中com.alibaba.fastjson.JSONObject.getDouble方法的典型用法代碼示例。如果您正苦於以下問題:Java JSONObject.getDouble方法的具體用法?Java JSONObject.getDouble怎麽用?Java JSONObject.getDouble使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.alibaba.fastjson.JSONObject
的用法示例。
在下文中一共展示了JSONObject.getDouble方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: convert
import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
@Override
public ArrayList<MultipleItemEntity> convert() {
final JSONArray array = JSON.parseObject(getJsonData()).getJSONArray("data");
final int size = array.size();
for (int i = 0; i < size; i++) {
final JSONObject data = array.getJSONObject(i);
final String thumb = data.getString("thumb");
final String title = data.getString("title");
final int id = data.getInteger("id");
final double price = data.getDouble("price");
final String time = data.getString("time");
final MultipleItemEntity entity = MultipleItemEntity.builder()
.setItemType(OrderListItemType.ITEM_ORDER_LIST)
.setField(MultipleFields.ID, id)
.setField(MultipleFields.IMAGE_URL, thumb)
.setField(MultipleFields.TITLE, title)
.setField(OrderItemFields.PRICE, price)
.setField(OrderItemFields.TIME, time)
.build();
ENTITIES.add(entity);
}
return ENTITIES;
}
示例2: drag
import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
private static boolean drag(JSONObject args) throws Exception {
String elementId = args.getString("element");
Double fromX = args.getDouble("fromX");
Double fromY = args.getDouble("fromY");
Double toX = args.getDouble("toX");
Double toY = args.getDouble("toY");
double duration = args.getDoubleValue("duration");
int steps = (int) Math.round(duration * 40);
if (elementId != null) {
Element el = elements.getElement(elementId);
return el.drag(toX.intValue(), toY.intValue(), steps);
} else {
boolean res = mDevice.drag(fromX.intValue(), fromY.intValue(), toX.intValue(), toY.intValue(), steps);
Thread.sleep(steps * 100);
return res;
}
}
示例3: getDouble
import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
public static double getDouble(String json, String key,
double defaultVal) {
JSONObject jsonObject = JSONObject.parseObject(json);
try {
if (jsonObject == null) {
return defaultVal;
}
if (jsonObject.containsKey(key)) {
return jsonObject.getDouble(key);
} else {
return defaultVal;
}
} catch (Exception e) {
return defaultVal;
}
}
示例4: getBitstampIndex
import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
@Override
public ExInfoBean getBitstampIndex(String type) {
ExInfoBean eb = new ExInfoBean();
String content = "";
try {
content = getTicker(type);
JSONObject jsonObj = JSON.parseObject(content);
double price = jsonObj.getDouble("last");
double volume = jsonObj.getDouble("volume");
if (price > 0 && volume > 0) {
eb.setPrice(price);
eb.setVolume(volume);
eb.ExBeanToPrint("bitstamp");
}
} catch (BitSTDException e) {
e.printStackTrace();
}
return eb;
}
示例5: convert
import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
@Override
public ArrayList<MultipleItemEntity> convert() {
final ArrayList<MultipleItemEntity> dataList = new ArrayList<>();
final JSONArray dataArray = JSON.parseObject(getJsonData()).getJSONArray("data");
final int size = dataArray.size();
for (int i = 0; i < size; i++) {
final JSONObject data = dataArray.getJSONObject(i);
final String thumb = data.getString("thumb");
final String desc = data.getString("desc");
final String title = data.getString("title");
final int id = data.getInteger("id");
final int count = data.getInteger("count");
final double price = data.getDouble("price");
final MultipleItemEntity entity = MultipleItemEntity.builder()
.setField(MultipleFields.ITEM_TYPE, ShopCartItemType.SHOP_CART_ITEM)
.setField(MultipleFields.ID, id)
.setField(MultipleFields.IMAGE_URL, thumb)
.setField(ShopCartItemFields.TITLE, title)
.setField(ShopCartItemFields.DESC, desc)
.setField(ShopCartItemFields.COUNT, count)
.setField(ShopCartItemFields.PRICE, price)
.setField(ShopCartItemFields.IS_SELECTED, false)
.setField(ShopCartItemFields.POSITION, i)
.build();
dataList.add(entity);
}
return dataList;
}
示例6: getDoubleFromDataByKey
import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**
* 根據key獲取返回對象data中的double(隻是第一層key),需要soa響應狀態碼是0
*
* @param result
* @param key
* @return
* @author xuxiao
* @created 2014年5月7日 下午6:00:25
*/
public static Double getDoubleFromDataByKey(final String result, final String key) {
final JSONObject data = getDataObj(result);
if (null != data) {
return data.getDouble(key);
} else {
return null;
}
}