本文整理匯總了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);
}
}
示例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;
}
}
示例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();
}
}
示例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;
}
示例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");
}
示例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";
}
示例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;
}
示例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;
}
}
示例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;
}
示例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) {
}
}
示例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();
}
示例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");
}
示例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;
}
}
示例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);
}
}
示例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;
}