本文整理汇总了Java中org.json.JSONObject.optLong方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.optLong方法的具体用法?Java JSONObject.optLong怎么用?Java JSONObject.optLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.json.JSONObject
的用法示例。
在下文中一共展示了JSONObject.optLong方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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.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);
return info;
}
示例2: 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;
}
示例3: fromJsonString
import org.json.JSONObject; //导入方法依赖的package包/类
public static FileInfo fromJsonString(String jsonString) {
FileInfo fileInfo = new FileInfo();
if (!TextUtils.isEmpty(jsonString)) {
try {
JSONObject jsonObject = new JSONObject(jsonString);
fileInfo.code = jsonObject.optInt("code", 500);
fileInfo.message = jsonObject.optString("message", "服务器内部错误");
fileInfo.mimeType = jsonObject.optString("mimeType", "unknown");
fileInfo.name = jsonObject.optString("name", "fileName");
fileInfo.fileSize = jsonObject.optLong("fileSize", 0);
fileInfo.createDate = jsonObject.optLong("createDate", System.currentTimeMillis());
fileInfo.hash = jsonObject.optString("hash", "-1");
} catch (JSONException e) {
e.printStackTrace();
}
}
return fileInfo;
}
示例4: update
import org.json.JSONObject; //导入方法依赖的package包/类
@Override
public void update(JSONObject json) {
position = json.optInt("position");
if(overwrites == null) overwrites = new TLongObjectHashMap<>();
TLongSet toRemove = new TLongHashSet(overwrites.keys());
JSONArray array = json.getJSONArray("permission_overwrites");
for(int i = 0, j = array.length(); i < j; i++) {
JSONObject overwrite = array.getJSONObject(i);
long id = overwrite.getLong("id");
toRemove.remove(id);
overwrites.put(id, new CachedOverwrite(overwrite));
}
for(TLongIterator it = toRemove.iterator(); it.hasNext();) {
overwrites.remove(it.next());
}
name = json.optString("name");
topic = json.optString("topic");
nsfw = json.optBoolean("nsfw");
lastMessageId = json.optLong("last_message_id");
bitrate = json.optInt("bitrate");
userLimit = json.optInt("user_limit");
parentId = json.optLong("parent_id");
}
示例5: update
import org.json.JSONObject; //导入方法依赖的package包/类
public void update(JSONObject json) {
name = json.getString("name");
icon = json.optString("icon", null);
splash = json.optString("splash", null);
ownerId = json.getLong("owner_id");
region = json.getString("region");
afkChannelId = json.optLong("afk_channel_id", -1);
afkTimeout = json.optInt("afk_timeout", -1);
embedEnabled = json.optBoolean("embed_enabled");
embedChannelId = json.optLong("embed_channel_id", -1);
verificationLevel = (byte)json.getInt("verification_level");
defaultMessageNotifications = (byte)json.getInt("default_message_notifications");
explicitContentFilter = (byte)json.getInt("explicit_content_filter");
JSONArray array = json.getJSONArray("features");
String[] f = new String[array.length()];
for(int i = 0; i < f.length; i++) {
f[i] = array.getString(i);
}
features = f;
mfaLevel = (byte)json.getInt("mfa_level");
applicationId = json.optLong("application_id", -1);
widgetEnabled = json.optBoolean("widget_enabled");
widgetChannelId = json.optLong("widget_channel_id", -1);
}
示例6: SkuDetails
import org.json.JSONObject; //导入方法依赖的package包/类
public SkuDetails(String itemType, String jsonSkuDetails) throws JSONException {
mItemType = itemType;
mJson = jsonSkuDetails;
JSONObject o = new JSONObject(mJson);
mSku = o.optString("productId");
mType = o.optString("type");
mPrice = o.optString("price");
mPriceAmountMicros = o.optLong("price_amount_micros");
mPriceCurrencyCode = o.optString("price_currency_code");
mTitle = o.optString("title");
mDescription = o.optString("description");
}
示例7: 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;
}
示例8: 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"));
mSignature = signature;
}
示例9: IE_Conversation
import org.json.JSONObject; //导入方法依赖的package包/类
IE_Conversation(@NonNull JSONObject pConversationItem) throws JSONException {
super();
this.conversation_id = pConversationItem.getLong("conversation_id");
this.last_message_abstract = IU_Utils.fromHtml(pConversationItem.getString("last_message_abstract"), null, null);
this.last_message_date = pConversationItem.getLong("last_message_date");
this.last_message_writer = pConversationItem.optLong("last_message_writer");
this.last_message_writer_type = pConversationItem.optInt("last_message_writer_type");
this.unread = pConversationItem.optInt("unread", 0) == 1;
pConversationItem = pConversationItem.optJSONObject("last_account");
this.last_account__name = pConversationItem == null ? null : IU_Utils.jsonOptStringWithNullCheck(pConversationItem, "name");
}
示例10: c
import org.json.JSONObject; //导入方法依赖的package包/类
public static MQConversation c(JSONObject jSONObject) {
MQConversation mQConversation = new MQConversation();
long optLong = jSONObject.optLong("id");
int optInt = jSONObject.optInt("assignee");
long optLong2 = jSONObject.optLong("enterprise_id");
long a = i.a(jSONObject.optString("created_on"));
mQConversation.setAssignee(optInt);
mQConversation.setEnterprise_id(optLong2);
mQConversation.setCreated_on(a);
mQConversation.setId(optLong);
return mQConversation;
}
示例11: onCreate
import org.json.JSONObject; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Entity$$CREATOR.create("", false);
limitJsonTv = (TextView) findViewById(R.id.limitjson_ms);
try {
JSONObject root = new JSONObject("");
root.opt("");
root.optInt("");
root.optBoolean("");
root.optLong("");
float aa = (float) root.optDouble("");
root.optString("");
root.optJSONObject("");
root.optJSONArray("");
int[] a;
if (root.has("arr")) {
JSONArray array = root.optJSONArray("");
int size = array.length();
a = new int[size];
for (int i = 0; i < size; i++) {
a[i] = array.optInt(i);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
testLimitJson();
LinearGraphView tu = (LinearGraphView) findViewById(R.id.line_graphic);
ArrayList<Double> yList = new ArrayList<Double>();
yList.add((double) 2.103);
yList.add(4.05);
yList.add(6.60);
yList.add(3.08);
yList.add(4.32);
yList.add(2.0);
yList.add(1115.0);
ArrayList<String> xRawDatas = new ArrayList<String>();
xRawDatas.add("05-19");
xRawDatas.add("05-20");
xRawDatas.add("05-21");
xRawDatas.add("05-22");
xRawDatas.add("05-23");
xRawDatas.add("05-24");
xRawDatas.add("05-25");
xRawDatas.add("05-26");
tu.setData(yList, xRawDatas, 8, 2);
}
示例12: provideState
import org.json.JSONObject; //导入方法依赖的package包/类
public void provideState(JSONObject json) {
updateTime = json.getLong("time");
position = json.optLong("position", 0);
}
示例13: parseJsonBody
import org.json.JSONObject; //导入方法依赖的package包/类
@Override
protected void parseJsonBody(@NonNull JSONObject jsonBody) {
super.parseJsonBody(jsonBody);
mTimestamp = jsonBody.optLong(ATTR_TIMESTAMP);
}
示例14: Relic
import org.json.JSONObject; //导入方法依赖的package包/类
public Relic(JSONObject relicObj) {
this.relicID = relicObj.getString(RELIC_ID);
this.duration = relicObj.getInt(DURATION);
this.type = Utils.getValueOrNull(RelicType.class, relicObj.get(TYPE).toString());
this.activationTime = relicObj.optLong(ACTIVATION);
}
示例15: parse
import org.json.JSONObject; //导入方法依赖的package包/类
public static AlbumInfo parse(JSONObject object) {
AlbumInfo album = new AlbumInfo();
if (TextUtils.isEmpty(object.optString("id"))) {
album.pid = object.optLong("pid");
} else {
album.pid = object.optLong("id");
}
album.nameCn = object.optString("nameCn");
album.albumType = object.optString("albumType");
album.subTitle = object.optString("subTitle");
album.score = object.optString("score");
album.cid = object.optInt("cid");
album.type = object.optInt("type");
album.at = object.optInt(PushDataParser.AT);
album.releaseDate = object.optString("releaseDate");
album.platformVideoNum = object.optInt("platformVideoNum");
album.platformVideoInfo = object.optInt("platformVideoInfo");
album.episode = object.optString("episode");
album.nowEpisodes = object.optString("nowEpisodes");
album.isEnd = object.optInt("isEnd");
album.duration = object.optLong(DownloadVideoTable.COLUMN_DURATION);
album.directory = object.optString("directory");
album.starring = object.optString("starring");
album.description = object.optString("description");
album.area = object.optString("area");
album.language = object.optString("language");
album.instructor = object.optString("instructor");
album.subCategory = object.optString("subCategory");
album.style = object.optString("style");
album.playTv = object.optString("playTv");
album.school = object.optString("school");
album.controlAreas = object.optString("controlAreas");
album.disableType = object.optInt("disableType");
album.play = object.optInt("play");
album.jump = object.optInt("jump");
album.pay = object.optInt("pay");
album.download = object.optInt("download");
album.tag = object.optString("tag");
album.travelType = object.optString("travelType");
album.playCount = object.optLong("playCount");
album.varietyShow = object.optInt("varietyShow");
album.cornerMark = object.optString("cornerMark");
JSONObject picAll = object.optJSONObject("picCollections");
if (picAll == null || JSONObject.NULL.equals(picAll)) {
picAll = object.optJSONObject("picAll");
}
if (!(picAll == null || JSONObject.NULL.equals(picAll))) {
album.pic150_200 = picAll.optString("150*200");
album.pic300_300 = picAll.optString("300*300");
album.pic320_200 = picAll.optString("320*200");
album.pic400_300 = picAll.optString("400*300");
if (!TextUtils.isEmpty(picAll.optString("120*90"))) {
album.pic320_200 = picAll.optString("120*90");
}
if (!TextUtils.isEmpty(picAll.optString("200*150"))) {
album.pic320_200 = picAll.optString("200*150");
}
}
return album;
}