本文整理了Java中org.json.JSONObject.getLong()
方法的一些代码示例,展示了JSONObject.getLong()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.getLong()
方法的具体详情如下:
包路径:org.json.JSONObject
类名称:JSONObject
方法名:getLong
[英]Returns the value mapped by name if it exists and is a long or can be coerced to a long. Note that JSON represents numbers as doubles, so this is lossy; use strings to transfer numbers via JSON.
[中]返回按名称映射的值(如果该值存在且为long或可以强制为long)。请注意,JSON将数字表示为双精度,因此这是lossy;使用字符串通过JSON传输数字。
代码示例来源:origin: google/physical-web
/**
* Get extra long value.
* @param key The key of the stored value.
* @return The stored value.
* @throws JSONException If the mapping doesn't exist or is not the required type.
*/
public long getExtraLong(String key) throws JSONException {
return mExtraData.getLong(key);
}
代码示例来源:origin: google/physical-web
/**
* Get extra long value.
* @param key The key of the stored value.
* @return The stored value.
* @throws JSONException If the mapping doesn't exist or is not the required type.
*/
public long getExtraLong(String key) throws JSONException {
return mExtraData.getLong(key);
}
代码示例来源:origin: internetarchive/heritrix3
/**
* Restore internal state from JSONObject stored at earlier
* checkpoint-time.
*
* @param json JSONObject
* @throws JSONException
*/
protected void fromCheckpointJson(JSONObject json) throws JSONException {
uriCount.set(json.getLong("uriCount"));
}
代码示例来源:origin: ankidroid/Anki-Android
public long getTimeLimit() {
long timebox = 0;
try {
timebox = mConf.getLong("timeLim");
} catch (JSONException e) {
throw new RuntimeException(e);
}
return timebox;
}
代码示例来源:origin: loklak/loklak_server
/**
* Check if the authentication is still valid
* @return true if the Authentication is still valid or does not have an expire time set. false otherwise
*/
public boolean checkExpireTime() {
return !this.json.has("expires_on") || this.json.getLong("expires_on") > Instant.now().getEpochSecond();
}
代码示例来源:origin: seven332/EhViewer
public static Result parse(String body, int vote) throws JSONException {
Result result = new Result();
JSONObject jo = new JSONObject(body);
result.id = jo.getLong("comment_id");
result.score = jo.getInt("comment_score");
result.vote = jo.getInt("comment_vote");
result.expectVote = vote;
return result;
}
}
代码示例来源:origin: internetarchive/heritrix3
@SuppressWarnings("unchecked")
public static void putAllLongs(Map<String,Long> targetMap, JSONObject sourceJson) throws JSONException {
for(String k : new Iteratorable<String>(sourceJson.keys())) {
targetMap.put(k, sourceJson.getLong(k));
}
}
代码示例来源:origin: internetarchive/heritrix3
@SuppressWarnings("unchecked")
public static void putAllAtomicLongs(Map<String,AtomicLong> targetMap, JSONObject sourceJson) throws JSONException {
for(String k : new Iteratorable<String>(sourceJson.keys())) {
targetMap.put(k, new AtomicLong(sourceJson.getLong(k)));
}
}
}
代码示例来源:origin: internetarchive/heritrix3
@Override
protected void fromCheckpointJson(JSONObject json) throws JSONException {
super.fromCheckpointJson(json);
numberOfLinksExtracted.set(json.getLong("numberOfLinksExtracted"));
}
代码示例来源:origin: ankidroid/Anki-Android
/** Add or update an existing model. Used for syncing and merging. */
public void update(JSONObject m) {
try {
mModels.put(m.getLong("id"), m);
} catch (JSONException e) {
throw new RuntimeException(e);
}
// mark registry changed, but don't bump mod time
save();
}
代码示例来源:origin: ankidroid/Anki-Android
public void updateConf(JSONObject g) {
try {
mDconf.put(g.getLong("id"), g);
} catch (JSONException e) {
throw new RuntimeException(e);
}
save();
}
代码示例来源:origin: ankidroid/Anki-Android
/**
* The currently selected did.
*/
public long selected() {
try {
return mCol.getConf().getLong("curDeck");
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: facebook/facebook-android-sdk
private static void readSettingFromCache(UserSetting userSetting) {
validateInitialized();
try {
String settingStr = userSettingPref.getString(userSetting.keyInCache, "");
if (!settingStr.isEmpty()) {
JSONObject setting = new JSONObject(settingStr);
userSetting.value = setting.getBoolean(VALUE);
userSetting.lastTS = setting.getLong(LAST_TIMESTAMP);
}
} catch (JSONException je) {
Utility.logd(TAG, je);
}
}
代码示例来源:origin: RipMeApp/ripme
/** Convert username to UserID. */
private String getUserID(String username) throws IOException {
LOGGER.info("Fetching user ID for " + username);
JSONObject json = new Http("https://api.500px.com/v1/" +
"users/show" +
"?username=" + username +
"&consumer_key=" + CONSUMER_KEY)
.getJSON();
return Long.toString(json.getJSONObject("user").getLong("id"));
}
代码示例来源:origin: ankidroid/Anki-Android
public int _deckNewLimitSingle(JSONObject g) {
try {
if (g.getInt("dyn") != 0) {
return mReportLimit;
}
JSONObject c = mCol.getDecks().confForDid(g.getLong("id"));
return Math.max(0, c.getJSONObject("new").getInt("perDay") - g.getJSONArray("newToday").getInt(1));
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: ankidroid/Anki-Android
private int _deckRevLimitSingle(JSONObject d) {
try {
if (d.getInt("dyn") != 0) {
return mReportLimit;
}
JSONObject c = mCol.getDecks().confForDid(d.getLong("id"));
return Math.max(0, c.getJSONObject("rev").getInt("perDay") - d.getJSONArray("revToday").getInt(1));
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: ankidroid/Anki-Android
private void maybeAddToActive() {
// reselect current deck, or default if current has disappeared
JSONObject c = current();
try {
select(c.getLong("id"));
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: ankidroid/Anki-Android
/** Note ids for M */
public ArrayList<Long> nids(JSONObject m) {
try {
return mCol.getDb().queryColumn(Long.class, "SELECT id FROM notes WHERE mid = " + m.getLong("id"), 0);
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: ankidroid/Anki-Android
/**
* Number of notes using m
* @param m The model to the count the notes of.
* @return The number of notes with that model.
*/
public int useCount(JSONObject m) {
try {
return mCol.getDb().queryScalar("select count() from notes where mid = " + m.getLong("id"));
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: ankidroid/Anki-Android
protected long getParentDid() {
long deckID;
try {
deckID = getCol().getDecks().current().getLong("id");
} catch (JSONException e) {
throw new RuntimeException(e);
}
return deckID;
}
内容来源于网络,如有侵权,请联系作者删除!