当前位置: 首页>>代码示例>>Java>>正文


Java JSONObject.getDouble方法代码示例

本文整理汇总了Java中org.json.JSONObject.getDouble方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.getDouble方法的具体用法?Java JSONObject.getDouble怎么用?Java JSONObject.getDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.json.JSONObject的用法示例。


在下文中一共展示了JSONObject.getDouble方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: detailsFrom

import org.json.JSONObject; //导入方法依赖的package包/类
static BusinessDetails detailsFrom(JSONObject information) {
    try {
        return new BusinessDetails(
            information.getDouble("rating"),
            information.has("price") ? PricingLevel.fromSymbol(information.getString("price")) : PricingLevel.NONE,
            information.getString("phone"),
            information.getString("id"),
            information.getBoolean("is_closed"),
            buildCategories(information.getJSONArray("categories")),
            information.getInt("review_count"),
            information.getString("name"),
            new URL(information.getString("url")),
            CoordinatesParser.from(information.getJSONObject("coordinates")),
            new URL(information.getString("image_url")),
            LocationParser.from(information.getJSONObject("location")),
            !information.isNull("distance") ? Distance.inMeters(information.getDouble("distance")) : null,
            buildTransactions(information.getJSONArray("transactions")),
            !information.isNull("is_claimed") && information.getBoolean("is_claimed"),
            !information.isNull("photos") ? buildPhotos(information.getJSONArray("photos")) : null,
            !information.isNull("hours") ? ScheduleParser.from(information.getJSONArray("hours")) : null
        );
    } catch (JSONException | MalformedURLException exception) {
        throw ParsingFailure.producedBy(information, exception);
    }
}
 
开发者ID:MontealegreLuis,项目名称:yelpv3-java-client,代码行数:26,代码来源:BusinessParser.java

示例2: newInstance

import org.json.JSONObject; //导入方法依赖的package包/类
static QNUser newInstance(String jsonString) {
    if (jsonString == null) {
        return null;
    }
    try {
        JSONObject jsonObject = new JSONObject(jsonString);
        QNUser user = new QNUser(jsonObject.getString("id"));
        user.height = jsonObject.getInt("height");
        user.gender = jsonObject.getInt(SocializeProtocolConstants.PROTOCOL_KEY_GENDER);
        if (jsonObject.has("birthday")) {
            user.birthday = new Date(jsonObject.getLong("birthday"));
        }
        user.weight = (float) jsonObject.getDouble("weight");
        user.resistance = jsonObject.getInt("resistance");
        return user;
    } catch (JSONException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:QNUser.java

示例3: getDesk

import org.json.JSONObject; //导入方法依赖的package包/类
@Override
public void getDesk(JSONObject result) {

    try {
        JSONArray desks = result.getJSONArray("baskets");
        for (int i=0; i<desks.length(); i++){
            JSONObject desk = (JSONObject) desks.get(i);
            name = desk.getString("name");
            image = desk.getString("image");
            piece = desk.getInt("piece");
            price = desk.getDouble("total");
            basketID = desk.getInt("basketID");

            product = new Product(piece, name, image, price, basketID);
            productList.add(product);

        }

        deskOrderAdapter = new DeskOrderAdapter(this, productList);
        lvBasket.setAdapter(deskOrderAdapter);

    } catch (JSONException e) {
        e.printStackTrace();
    }

}
 
开发者ID:yusufcakal,项目名称:RestaurantApp,代码行数:27,代码来源:DeskBasketActivity.java

示例4: a

import org.json.JSONObject; //导入方法依赖的package包/类
public synchronized Fallback a(JSONObject jSONObject) {
    this.a = jSONObject.optString(c.a);
    this.n = jSONObject.getLong("ttl");
    this.l = jSONObject.getDouble("pct");
    this.i = jSONObject.getLong(DeviceInfo.TAG_TIMESTAMPS);
    this.d = jSONObject.optString("city");
    this.c = jSONObject.optString("prv");
    this.g = jSONObject.optString("cty");
    this.e = jSONObject.optString("isp");
    this.f = jSONObject.optString("ip");
    this.b = jSONObject.optString(com.alipay.sdk.cons.c.f);
    this.h = jSONObject.optString("xf");
    JSONArray jSONArray = jSONObject.getJSONArray("fbs");
    for (int i = 0; i < jSONArray.length(); i++) {
        a(new e().a(jSONArray.getJSONObject(i)));
    }
    return this;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:Fallback.java

示例5: IexQuote

import org.json.JSONObject; //导入方法依赖的package包/类
public IexQuote(JSONObject message) {
    this.type = message.getString("type");
    this.ticker = message.getString("ticker");
    this.price = message.getDouble("price");
    this.size = message.getLong("size");
    this.timestamp = message.getDouble("timestamp");
}
 
开发者ID:intrinio,项目名称:intrinio-realtime-java-sdk,代码行数:8,代码来源:IexQuote.java

示例6: Parcheggio

import org.json.JSONObject; //导入方法依赖的package包/类
/**
 * Costruttore per l'assegnamento del parcheggio da un oggetto JSON, utilizzato durante il
 * download dei parcheggi tramite IelloApi.
 * @throws JSONException dovuta alla conversione dell'oggetto JSON in dati del parcheggio
 */
public Parcheggio(JSONObject jParcheggio) throws JSONException {
    mId = jParcheggio.getString("id");

    mCoordinate = new LatLng(jParcheggio.getDouble("latitude"), jParcheggio.getDouble("longitude"));
    if(jParcheggio.has("street_address"))
        mIndirizzo = jParcheggio.getString("street_address");
    else
        mIndirizzo = "Ind. non disponibile";
}
 
开发者ID:IelloDevTeam,项目名称:IelloAndroidAdminApp,代码行数:15,代码来源:Parcheggio.java

示例7: getFromJsonByField2

import org.json.JSONObject; //导入方法依赖的package包/类
/**
 * 
 * @param json
 * @param key
 * @param toField
 * @return
 * @throws JSONException
 */
public static Object getFromJsonByField2(JSONObject json, String key, Field toField) throws JSONException {
	final Object o = json.get(key);
	final Class<?> fieldType = toField.getType();
	if (o != JSONObject.NULL) {
		if (fieldType.equals(Integer.class) || fieldType.equals(Integer.TYPE)) {
			return json.getInt(key);
		}
		else if (fieldType.equals(String.class)) {
			return o;
		}
		else if (fieldType.equals(Long.class) || fieldType.equals(Long.TYPE)) {
			return json.getLong(key);
		}
		else if (fieldType.equals(Boolean.class) || fieldType.equals(Boolean.TYPE)) {
			return json.getBoolean(key);
		}
		else if (fieldType.equals(Float.class) || fieldType.equals(Float.TYPE)) {
			return (float) json.getDouble(key);
		}
		else if (fieldType.equals(Double.class) || fieldType.equals(Double.TYPE)) {
			return json.getDouble(key);
		}
		else {
			return o;
		}			
	}

	return JSONObject.NULL;
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:38,代码来源:HstoreParser.java

示例8: findAll

import org.json.JSONObject; //导入方法依赖的package包/类
public void findAll() {
    try {
        status = json.getString("status");

        JSONArray jarr = json.getJSONArray("results");
        JSONObject job = jarr.getJSONObject(0);
        JSONArray jarr1 = job.getJSONArray("address_components");

        address = job.getString("formatted_address");

        JSONObject geo = job.getJSONObject("geometry");
        JSONObject gloc = geo.getJSONObject("location");
        lat = gloc.getDouble("lat");
        lng = gloc.getDouble("lng");


        for (int i = 0; i < jarr1.length(); i++) {
            JSONObject jo = jarr1.getJSONObject(i);
            String temp = jo.getString("types");
            String val = jo.getString("long_name");
            String val2 = jo.getString("short_name");
            setData(temp, val, val2);
        }

        String ttmp = job.getString("types");
        String tempp = ttmp.substring(ttmp.indexOf("\"") + 1, ttmp.length());
        type = tempp.substring(0, tempp.indexOf("\""));

        isSuccess= true;
    } catch (Exception e) {
        Log.d("Error Shivam ", e.toString());
        isSuccess= false;
    }
}
 
开发者ID:shivam301296,项目名称:True-Weather,代码行数:35,代码来源:MyGoogleLocation.java

示例9: jsonDeserialize

import org.json.JSONObject; //导入方法依赖的package包/类
/**
 * Populates a UrlInfo with data from a given JSON object.
 * @param jsonObject a serialized UrlInfo.
 * @return The UrlInfo represented by the serialized object.
 * @throws JSONException if the values cannot be serialized.
 */
public static UrlInfo jsonDeserialize(JSONObject jsonObject) throws JSONException {
    UrlInfo urlInfo = new UrlInfo(
            jsonObject.getString(URL_KEY),
            jsonObject.getDouble(DISTANCE_KEY),
            jsonObject.getLong(SCAN_TIMESTAMP_KEY));
    if (jsonObject.optBoolean(HAS_BEEN_DISPLAYED_KEY, false)) {
        urlInfo.setHasBeenDisplayed();
    }
    return urlInfo;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:17,代码来源:UrlInfo.java

示例10: j2cvFloat

import org.json.JSONObject; //导入方法依赖的package包/类
private static void j2cvFloat(JSONObject j, ContentValues cv, String key) {
	try {
		float v = (float) j.getDouble(key);
		cv.put(key, v);
	} catch (JSONException e) {
	}
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:8,代码来源:Columns.java

示例11: decode

import org.json.JSONObject; //导入方法依赖的package包/类
static PlaybackStatus decode(JSONObject json) throws JSONException {
    PlaybackStatus.Builder builder = new PlaybackStatus.Builder();
    double position = json.getDouble(KEY_POSITION);
    builder.setPosition(position);
    double duration = json.getDouble(KEY_DURATION);
    builder.setDuration(duration);
    String state = json.getString(KEY_STATUS);
    try {
        builder.setState(PlaybackState.valueOf(state.toUpperCase()));
    } catch(IllegalArgumentException e) {
        throw new JSONException("invalid status:" + state);
    }
    return builder.build();
}
 
开发者ID:Orange-OpenSource,项目名称:OCast-Java,代码行数:15,代码来源:PlaybackStatus.java

示例12: QueryOrderParametersImpl

import org.json.JSONObject; //导入方法依赖的package包/类
QueryOrderParametersImpl(final JSONObject jsonObject) throws JSONException {
    lowerLimit = jsonObject.getDouble("lower_limit");
    price = jsonObject.getDouble("price");
    upperLimit = jsonObject.getDouble("upper_limit");
    isZeroConfEnabled = jsonObject.getBoolean("zero_conf_enabled");
    zeroConfMaxAmount = jsonObject.getDouble("zero_conf_max_amount");
}
 
开发者ID:m2049r,项目名称:xmrwallet,代码行数:8,代码来源:QueryOrderParametersImpl.java

示例13: getDouble

import org.json.JSONObject; //导入方法依赖的package包/类
/**
 * 获取JSONObject中为key值对应的double数据(外部json数据专用)
 * @param key 需要获取的key
 * @return key值对应的double数据
 */
public static double getDouble(JSONObject jsonData,String key)  {
    if (!hasKey(jsonData,key)) {
        return 0;
    }
    try {
        return jsonData.getDouble(key);
    } catch (JSONException e) {
        return 0;
    }
}
 
开发者ID:luck-fc,项目名称:Interface_Json_Model,代码行数:16,代码来源:JsonUtil.java

示例14: parseJSON

import org.json.JSONObject; //导入方法依赖的package包/类
/**
 * 
 */
public void parseJSON(JSONObject jTimeslice) {
  parseDates(jTimeslice);
  JSONObject jValues = jTimeslice.getJSONObject("values");
  Iterator<String> iter = jValues.keys();
  while (iter.hasNext()) {
    String key = iter.next();
    Double value = jValues.getDouble(key);
    valueMap.put(key, value);
  }
}
 
开发者ID:kenahrens,项目名称:newrelic-api-client-java,代码行数:14,代码来源:Timeslice.java

示例15: getDouble

import org.json.JSONObject; //导入方法依赖的package包/类
public static double getDouble(JSONObject obj, String key, double defaultValue) {
	try {
		if (isKeyNotNull(obj, key)) {
			return obj.getDouble(key);
		}
	} catch (Throwable e) {
		DLog.e(e);
	}
	return defaultValue;
}
 
开发者ID:youmi,项目名称:nativead,代码行数:11,代码来源:JSONUtils.java


注:本文中的org.json.JSONObject.getDouble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。