當前位置: 首頁>>代碼示例>>Java>>正文


Java JSONObject.optInt方法代碼示例

本文整理匯總了Java中org.json.JSONObject.optInt方法的典型用法代碼示例。如果您正苦於以下問題:Java JSONObject.optInt方法的具體用法?Java JSONObject.optInt怎麽用?Java JSONObject.optInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.json.JSONObject的用法示例。


在下文中一共展示了JSONObject.optInt方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setSpecialInterval

import org.json.JSONObject; //導入方法依賴的package包/類
public void setSpecialInterval(JSONObject jsonObject) {
    if (jsonObject != null) {
        this.mSpecialInterval = new SparseIntArray();
        Iterator<String> itr = jsonObject.keys();
        while (itr.hasNext()) {
            String key = itr.next();
            try {
                int index = Integer.parseInt(key);
                int value = jsonObject.optInt(key);
                if (value > 0) {
                    this.mSpecialInterval.put(index, value);
                }
            } catch (NumberFormatException e) {
            }
        }
    }
}
 
開發者ID:alibaba,項目名稱:Tangram-Android,代碼行數:18,代碼來源:BannerCell.java

示例2: run

import org.json.JSONObject; //導入方法依賴的package包/類
public final void run() {
    d dVar = this.b;
    a aVar = this.a;
    if (aVar != null && "toast".equals(aVar.k)) {
        JSONObject jSONObject = aVar.m;
        CharSequence optString = jSONObject.optString(Utils.RESPONSE_CONTENT);
        int optInt = jSONObject.optInt(SportRecordDao.DURATION);
        int i = 1;
        if (optInt < DefaultRetryPolicy.DEFAULT_TIMEOUT_MS) {
            i = 0;
        }
        Toast.makeText(dVar.b, optString, i).show();
        new Timer().schedule(new f(dVar, aVar), (long) i);
    }
    a aVar2 = a.NONE_ERROR;
    if (aVar2 != a.NONE_ERROR) {
        try {
            this.b.a(this.a.i, aVar2);
        } catch (JSONException e) {
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:23,代碼來源:e.java

示例3: parse

import org.json.JSONObject; //導入方法依賴的package包/類
public static Card parse(JSONObject obj) {
    if (obj == null) {
        return null;
    }
    Card card = new Card();
    card.card_type = obj.optInt("card_type", 0);
    card.show_type = obj.optInt("show_type", 0);

    JSONArray cardGroups = obj.optJSONArray("card_group");
    if (cardGroups != null && cardGroups.length() > 0) {
        card.card_group = new ArrayList<>(cardGroups.length());
        for (int i = 0; i < cardGroups.length(); i++) {
            CardGroup cardGroup = CardGroup.parse(cardGroups.optJSONObject(i));
            if (cardGroup != null) {
                card.card_group.add(cardGroup);
            }
        }
    }
    card.openurl = obj.optString("openurl", "");

    card.mblog = MBlog.parse(obj.optJSONObject("mblog"));
    return card;
}
 
開發者ID:liying2008,項目名稱:Simpler,代碼行數:24,代碼來源:Card.java

示例4: parse

import org.json.JSONObject; //導入方法依賴的package包/類
public static User parse(JSONObject obj) {
    if (obj == null) {
        return null;
    }
    User user = new User();
    user.id = obj.optLong("id", 0L);
    user.screen_name = obj.optString("screen_name", "");
    user.profile_image_url = obj.optString("profile_image_url", "");
    user.profile_url = obj.optString("profile_url", "");
    user.statuses_count = obj.optInt("statuses_count", 0);
    user.verified = obj.optBoolean("verified", false);
    user.verified_type = obj.optInt("verified_type", -1);
    user.verified_reason = obj.optString("verified_reason", "");
    user.description = obj.optString("description", "");
    user.gender = obj.optString("gender", "");
    user.mbtype = obj.optInt("mbtype", 0);
    user.urank = obj.optInt("urank", 0);
    user.mbrank = obj.optInt("mbrank", 0);
    user.follow_me = obj.optBoolean("follow_me", false);
    user.following = obj.optBoolean("following", false);
    user.followers_count = obj.optInt("followers_count", 0);
    user.follow_count = obj.optInt("follow_count", 0);
    user.cover_image_phone = obj.optString("cover_image_phone", "");
    return user;
}
 
開發者ID:liying2008,項目名稱:Simpler,代碼行數:26,代碼來源:User.java

示例5: setOrientation

import org.json.JSONObject; //導入方法依賴的package包/類
/**
 * 設置橫豎屏
 * <p>
 * 參數:
 * orientation:1表示豎屏,0表示橫屏,其他表示跟隨係統
 */
public static void setOrientation(IQuickFragment webLoader, WebView wv, JSONObject param, Callback callback) {
    int orientation = param.optInt("orientation", ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    if (orientation >= ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED && orientation <= ActivityInfo.SCREEN_ORIENTATION_LOCKED) {
        webLoader.getPageControl().getActivity().setRequestedOrientation(orientation);
        callback.applySuccess();
    } else {
        callback.applyFail("orientation值超出範圍,請設置-1到14");
    }
}
 
開發者ID:quickhybrid,項目名稱:quickhybrid-android,代碼行數:16,代碼來源:DeviceApi.java

示例6: parseGroup

import org.json.JSONObject; //導入方法依賴的package包/類
@Nullable
@Override
public List<Card> parseGroup(@Nullable JSONArray data, ServiceManager serviceManager) {
    final CardResolver cardResolver = serviceManager.getService(CardResolver.class);
    Preconditions.checkState(cardResolver != null, "Must register CardResolver into ServiceManager first");
    final MVHelper cellResolver = serviceManager.getService(MVHelper.class);
    Preconditions.checkState(cellResolver != null, "Must register CellResolver into ServiceManager first");
    final int size = data.length();
    final List<Card> result = new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
        JSONObject cardData = data.optJSONObject(i);
        if (cardData != null) {
            //maybe custom card
            final String cardType = cardData.optString(Card.KEY_TYPE);
            if (!TextUtils.isEmpty(cardType)) {
                final Card card = cardResolver.create(cardType);
                if (card != null) {
                    card.rowId = i;
                    card.serviceManager = serviceManager;
                    //add card style
                    addCardStyle(cardData, card);
                    //custom items element key if need.
                    transformCardCellData(cardData);
                    //parser card
                    card.parseWith(cardData, cellResolver);
                    card.type = cardData.optInt(Card.KEY_TYPE, -1);
                    card.stringType = cardType;
                    result.add(card);
                }
            }
        }
    }
    cellResolver.resolver().setCards(result);
    return result;
}
 
開發者ID:alibaba,項目名稱:Tangram-Android,代碼行數:36,代碼來源:SampleDataParser.java

示例7: parseFeature

import org.json.JSONObject; //導入方法依賴的package包/類
@NonNull
@VisibleForTesting
protected Feature parseFeature(@NonNull JSONObject feature) throws JSONException, DatasourceParsingException {
    final String name = JSONTools.optString(feature, "name", null);
    if (TextUtils.isEmpty(name)) {
        throw new DatasourceParsingException("Features must have a name.");
    }

    final Feature retVal = new Feature();
    retVal.name = name;
    retVal.initialLifetime = feature.optInt("ttl", Feature.UNLIMITED_LIFETIME);
    retVal.remainingLifetime = retVal.initialLifetime;
    return retVal;
}
 
開發者ID:AppGratis,項目名稱:unlock-android,代碼行數:15,代碼來源:DatasourceParser.java

示例8: KanboardSwimlane

import org.json.JSONObject; //導入方法依賴的package包/類
public KanboardSwimlane(JSONObject swimlane) {
    if (swimlane.has("default_swimlane")) {
        Id = 0;
        Name = swimlane.optString("default_swimlane");
        IsActive = KanboardAPI.StringToBoolean(swimlane.optString("show_default_swimlane"));
        IsDefault = true;
    } else {
        Id = swimlane.optInt("id");
        Name = swimlane.optString("name");
        Description = swimlane.optString("description");
        Position = swimlane.optInt("position");
        ProjectId = swimlane.optInt("project_id");
        IsActive = KanboardAPI.StringToBoolean(swimlane.optString("is_active"));
    }
}
 
開發者ID:andresth,項目名稱:Kandroid,代碼行數:16,代碼來源:KanboardSwimlane.java

示例9: fromJson

import org.json.JSONObject; //導入方法依賴的package包/類
public static FieldAngle fromJson(JSONObject json) throws BlockLoadingException {
    String name = json.optString("name");
    if (TextUtils.isEmpty(name)) {
        throw new BlockLoadingException("field_angle \"name\" attribute must not be empty.");
    }

    return new FieldAngle(name, json.optInt("angle", 90));
}
 
開發者ID:Axe-Ishmael,項目名稱:Blockly,代碼行數:9,代碼來源:FieldAngle.java

示例10: parse

import org.json.JSONObject; //導入方法依賴的package包/類
private static UpdateInfo parse(JSONObject o) {
    UpdateInfo info = new UpdateInfo ();
    if (o == null) {
        return info;
    }
    info.hasUpdate = o.optBoolean("hasUpdate", false);
    if (!info.hasUpdate) {
        return info;
    }
    info.isSilent = o.optBoolean("isSilent", false);
    info.isForce = o.optBoolean("isForce", false);
    info.isAutoInstall = o.optBoolean("isAutoInstall", !info.isSilent);
    info.isIgnorable = o.optBoolean("isIgnorable", true);
    info.isPatch = o.optBoolean("isPatch", false);

    info.versionCode = o.optInt("versionCode", 0);
    info.versionName = o.optString("versionName");
    info.updateContent = o.optString("updateContent");

    info.url = o.optString("url");
    info.md5 = o.optString("md5");
    info.size = o.optLong("size", 0);

    if (!info.isPatch) {
        return info;
    }
    info.patchUrl = o.optString("patchUrl");
    info.patchMd5 = o.optString("patchMd5");
    info.patchSize = o.optLong("patchSize", 0);
    return info;
}
 
開發者ID:zhanghangyes,項目名稱:updateUtils,代碼行數:32,代碼來源:UpdateInfo.java

示例11: parse

import org.json.JSONObject; //導入方法依賴的package包/類
public static Tag parse(JSONObject jsonObject) {
    if (null == jsonObject) {
        return null;
    }
    
    Tag tag = new Tag();
    tag.id  = jsonObject.optInt("id", 0);
    tag.tag = jsonObject.optString("tag", "");
    
    return tag;
}
 
開發者ID:LingjuAI,項目名稱:AssistantBySDK,代碼行數:12,代碼來源:Tag.java

示例12: Purchase

import org.json.JSONObject; //導入方法依賴的package包/類
public Purchase(String itemType, String jsonPurchaseInfo, String signature) throws JSONException {
    mItemType = itemType;
    mOriginalJson = jsonPurchaseInfo;
    JSONObject o = new JSONObject(mOriginalJson);
    mOrderId = o.optString("orderId");
    mPackageName = o.optString("packageName");
    mSku = o.optString("productId");
    mPurchaseTime = o.optLong("purchaseTime");
    mPurchaseState = o.optInt("purchaseState");
    mDeveloperPayload = o.optString("developerPayload");
    mToken = o.optString("token", o.optString("purchaseToken"));
    mIsAutoRenewing = o.optBoolean("autoRenewing");
    mSignature = signature;
}
 
開發者ID:sarveshchavan7,項目名稱:Trivia-Knowledge,代碼行數:15,代碼來源:Purchase.java

示例13: parseItem

import org.json.JSONObject; //導入方法依賴的package包/類
private Gif parseItem(JSONObject object) {
    String url = object.optString("url");
    String preview = object.optString("fixedUrl");
    int width = object.optInt("width");
    int height = object.optInt("height");
    String title = object.optString("title");

    return Gif.Builder.newInstance()
            .height(height)
            .width(width)
            .preview(preview)
            .url(url)
            .title(title)
            .build();
}
 
開發者ID:auv1107,項目名稱:TextEmoji,代碼行數:16,代碼來源:SooGifRemoteDataSource.java

示例14: opretUdsendelse

import org.json.JSONObject; //導入方法依賴的package包/類
private static Udsendelse opretUdsendelse(Programdata data, JSONObject o) throws JSONException {
  String slug = o.optString("Slug");  // Bemærk - kan være tom!
  Udsendelse u = new Udsendelse();
  u.slug = slug;
  data.udsendelseFraSlug.put(u.slug, u);
  u.titel = o.getString("Title");
  u.beskrivelse = o.getString("Description");
  u.billedeUrl = fjernHttpWwwDrDk(o.optString("ImageUrl", null));
  u.programserieSlug = o.optString("SeriesSlug");  // Bemærk - kan være tom!
  u.episodeIProgramserie = o.optInt("Episode");
  u.urn = o.optString("Urn");  // Bemærk - kan være tom!
  return u;
}
 
開發者ID:nordfalk,項目名稱:EsperantoRadio,代碼行數:14,代碼來源:GammelDrRadioBackend.java

示例15: fromJsonObject

import org.json.JSONObject; //導入方法依賴的package包/類
public static TradeInfo fromJsonObject(JSONObject jsonObject) {
    TradeInfo tradeInfo = new TradeInfo();
    tradeInfo.price = jsonObject.optString("price");
    tradeInfo.lepay_order_no = jsonObject.optString("lepay_order_no");
    tradeInfo.merchant_business_id = jsonObject.optString("merchant_business_id");
    tradeInfo.sign = jsonObject.optString(SIGN);
    tradeInfo.orderstatus = jsonObject.optInt("orderstatus");
    tradeInfo.product_urls = jsonObject.optString("product_urls");
    JSONArray jsonArray = jsonObject.optJSONArray("paylist");
    for (int i = 0; i < jsonArray.length(); i++) {
        tradeInfo.paylist.add(Paymodes.fromJsonObject(jsonArray.optJSONObject(i)));
    }
    return tradeInfo;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:15,代碼來源:TradeInfo.java


注:本文中的org.json.JSONObject.optInt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。