本文整理汇总了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;
}
}