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