本文整理汇总了Java中org.json.JSONObject.getLong方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.getLong方法的具体用法?Java JSONObject.getLong怎么用?Java JSONObject.getLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.json.JSONObject
的用法示例。
在下文中一共展示了JSONObject.getLong方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStage
import org.json.JSONObject; //导入方法依赖的package包/类
private static Stage getStage(JSONObject stageJSONObject) {
try {
int id = stageJSONObject.getInt("id");
long duration = stageJSONObject.getLong("duration");
int moves = stageJSONObject.getInt("moves");
if (moves > 0) {
return new Stage(id, duration, moves);
} else {
return new Stage(id, duration);
}
} catch (JSONException e) {
Log.e(TAG, e.getMessage());
e.printStackTrace();
return null;
}
}
示例2: Config
import org.json.JSONObject; //导入方法依赖的package包/类
public Config(Path path) throws IOException, JSONException
{
JSONObject json = new JSONObject(new String(Files.readAllBytes(path)));
JSONArray ownerIds = json.getJSONArray("owner_ids");
this.jagroshId = ownerIds.getLong(0);
this.monitorId = ownerIds.getLong(1);
this.token = json.getString("token");
this.databaseUsername = json.getString("database_username");
this.databasePassword = json.getString("database_password");
this.databasePathname = json.getString("database_pathname");
this.webhookId = json.getLong("webhook_id");
this.webhookToken = json.getString("webhook_token");
this.discordBotsKey = json.optString("discord_bots_key", null);
this.carbonitexKey = json.optString("carbonitex_key", null);
this.discordBotsListKey = json.optString("discord_bots_list_key", null);
}
示例3: parseIndexFile
import org.json.JSONObject; //导入方法依赖的package包/类
/**
* 解析 index 文件
*
* @return
*/
private boolean parseIndexFile() {
try {
String content = readFileOnce(LOGCAT_INDEX_FILE_NAME, 0);
if (content == null) {
deleteAllQosFiles();
return false;
}
JSONObject json = new JSONObject(String.valueOf(content));
mReadFileIndex = json.getLong(KEY_READ_FILE_INDEX);
mReadFilePosition = json.getLong(KEY_READ_FILE_POSITION);
mWriteFileIndex = json.getLong(KEY_WRITE_FILE_INDEX);
mWriteFilePosition = json.getLong(KEY_WRITE_FILE_POSITION);
return true;
} catch (JSONException e) {
e.printStackTrace();
}
deleteAllQosFiles();
return false;
}
示例4: buildInvite
import org.json.JSONObject; //导入方法依赖的package包/类
public Invite buildInvite(JSONObject json) {
String code = json.getString("code");
Guild guild = (Guild) identity.getGuild(json.getJSONObject("guild").getString("id"));
IGuildChannel channel = identity.getGuildChannel(json.getJSONObject("channel").getString("id"));
Invite invite = new Invite(code, guild, channel);
// If the invites has metadata object
if (json.has("inviter")) {
User inviter = (User) identity.getUser(json.getJSONObject("inviter").getString("id"));
int uses = json.getInt("uses");
int maxUses = json.getInt("max_uses");
long maxAge = json.getLong("max_age");
boolean isTemporary = json.has("temporary") && json.getBoolean("temporary");
boolean isRevoked = json.has("revoked") && json.getBoolean("revoked");
String timeStamp = json.getString("created_at");
invite.setMetaData(inviter, uses, maxUses, maxAge, isTemporary, isRevoked, timeStamp);
}
return invite;
}
示例5: Notification
import org.json.JSONObject; //导入方法依赖的package包/类
public Notification(JSONObject obj) throws JSONException {
id = obj.getString("1");
status = Status.parse(obj.getInt("2"));
timestamp = obj.getLong("4");
JSONObject notifInfo = obj.getJSONObject("3");
JSONObject notifBody = notifInfo.getJSONObject("2");
shortMessage = notifBody.getJSONObject("1").getString("2");
longMessage = notifBody.getJSONObject("2").getString("2");
JSONObject notifData = notifInfo.getJSONObject("3");
forApp = notifData.getString("1");
type = Type.parse(notifData.getInt("3"));
actions = new ArrayList<>();
JSONArray actions = notifData.optJSONArray("4");
if (actions != null) {
for (int i = 0; i < actions.length(); i++)
this.actions.add(new Action(actions.getJSONObject(i)));
}
}
示例6: DownloadDBBean
import org.json.JSONObject; //导入方法依赖的package包/类
public DownloadDBBean(JSONObject jsonObject) throws JSONException {
if (jsonObject != null) {
this.episodeid = jsonObject.getInt("episodeid");
this.albumId = (long) jsonObject.getInt(PageJumpUtil.IN_TO_ALBUM_PID);
this.icon = jsonObject.getString(SettingsJsonConstants.APP_ICON_KEY);
this.type = jsonObject.getInt("type");
this.cid = jsonObject.getInt("cid");
this.episodetitle = jsonObject.getString("episodetitle");
this.albumtitle = jsonObject.getString(DownloadAlbumTable.COLUMN_ALBUMTITLE);
this.totalsize = (long) jsonObject.getInt(DownloadVideoTable.COLUMN_TOTALSIZE);
this.finish = jsonObject.getInt("finish");
this.timestamp = (long) jsonObject.getInt("timestamp");
this.length = (long) jsonObject.getInt(DownloadVideoTable.COLUMN_LENGTH);
if (jsonObject.has(DownloadVideoTable.COLUMN_FILEPATH)) {
this.filePath = jsonObject.getString(DownloadVideoTable.COLUMN_FILEPATH);
}
this.isHd = jsonObject.getInt("isHd");
this.btime = jsonObject.getLong(DownloadVideoTable.COLUMN_BTIME);
this.etime = jsonObject.getLong(DownloadVideoTable.COLUMN_ETIME);
}
}
示例7: processStat
import org.json.JSONObject; //导入方法依赖的package包/类
/**
* Proccesses an individual stat entry
* @param name String
* @param facetVal JSONObject
* @return Stat
* @throws JSONException
*/
private StatsResultStat processStat(String name, JSONObject facetVal) throws JSONException
{
return new StatsResultStat(nameIsADate?formatAsDate(name):name,
facetVal.getLong("sum"),
facetVal.getLong("count"),
facetVal.getLong("min"),
facetVal.getLong("max"),
facetVal.getLong("mean"));
}
示例8: DeviceInfo
import org.json.JSONObject; //导入方法依赖的package包/类
public DeviceInfo(JSONObject json) {
try {
mAndroidVersion = json.getString("android_version");
mKernelVersion = json.getString("kernel_version");
mAppVersion = json.getString("app_version");
mBoard = json.getString("board");
mModel = json.getString("model");
mVendor = json.getString("vendor");
mCpuInfo = json.getString("cpuinfo");
mFingerprint = json.getString("fingerprint");
JSONArray commands = json.getJSONArray("commands");
mCommands = new ArrayList<>();
for (int i = 0; i < commands.length(); i++) {
mCommands.add(commands.getString(i));
}
JSONArray times = json.getJSONArray("times");
for (int i = 0; i < times.length(); i++) {
mAverageSOT += times.getInt(i);
}
mAverageSOT /= times.length();
mAverageSOT *= 100;
mCpu = json.getLong("cpu");
mScore = Math.round(json.getDouble("score"));
} catch (JSONException ignored) {
mValid = false;
}
}
示例9: LiveUpdate
import org.json.JSONObject; //导入方法依赖的package包/类
public LiveUpdate(String threadId, JSONObject entry) {
this.threadId = threadId;
this.author = entry.getString("author");
this.body = entry.getString("body");
this.id = UUID.fromString(entry.getString("id"));
this.created = entry.getLong("created_utc");
}
示例10: getGroup
import org.json.JSONObject; //导入方法依赖的package包/类
private static Group getGroup(long groupUid) {
JSONArray array = ((JSONObject) new JSONTokener(sendRequest("/get_group_list", null))
.nextValue()).getJSONArray("data");
for (Object thisObject : array) {
JSONObject item = (JSONObject) thisObject;
if (item.getLong("group_id") == groupUid)
return new Group(groupUid, item.getString("group_name"));
}
return null;
}
示例11: getJson
import org.json.JSONObject; //导入方法依赖的package包/类
public static ValueOut getJson(JSONObject json) throws JSONException {
ValueOut v = new ValueOut();
v.value=json.getString("value");
v.n=json.getLong("n");
v.spentTxId=json.getString("spentTxId");
v.spentIndex=json.getLong("spentIndex");
v.spentHeight=json.getLong("spentHeight");
v.scriptPubKey = ScriptPubKey.getJson(json.getJSONObject("scriptPubKey"));
return v;
}
示例12: ReleaseTrack
import org.json.JSONObject; //导入方法依赖的package包/类
public ReleaseTrack(JSONObject obj) throws JSONException {
which = Track.parse(obj.getInt("1"));
trackId = obj.getString("2");
versionCodes = new ArrayList<>();
apkIds = new ArrayList<>();
JSONObject releaseInfo = obj.optJSONObject("5");
JSONObject someData = obj.optJSONObject("7");
if (releaseInfo == null) {
if (someData == null) status = Status.EMPTY;
else status = Status.OUTDATED;
fullRollout = false;
rolloutTimestamp = -1;
versionName = null;
lastReleaseId = null;
} else {
versionName = releaseInfo.getJSONObject("1").getString("1");
lastReleaseId = releaseInfo.getString("6");
JSONArray versionCodesArray = releaseInfo.getJSONArray("3");
for (int i = 0; i < versionCodesArray.length(); i++)
versionCodes.add(versionCodesArray.getInt(i));
JSONArray apkIdsArray = releaseInfo.getJSONArray("8");
for (int i = 0; i < apkIdsArray.length(); i++)
apkIds.add(apkIdsArray.getString(i));
JSONObject rolloutInfo = releaseInfo.getJSONObject("2");
fullRollout = rolloutInfo.getInt("1") == 1;
rolloutTimestamp = rolloutInfo.getLong("2");
if (someData.optInt("3", -1) == 1) status = Status.OUTDATED;
else status = Status.NEWER;
}
}
示例13: from
import org.json.JSONObject; //导入方法依赖的package包/类
@Contract("null -> null")
private static IE_Admin from(@Nullable JSONObject json) {
if(json == null)
return null;
try {
return new IE_Admin(json.getLong("account_id"), json.getString("name"), json.getLong("last_active"));
} catch (JSONException e) {
return null;
}
}
示例14: 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;
}
示例15: backupDataFromJSON
import org.json.JSONObject; //导入方法依赖的package包/类
protected void backupDataFromJSON(JSONObject secureData, T backupData) throws JSONException {
final String mnemonic = secureData.getString("mnemonic");
final long creationTime = secureData.getLong("creationTime");
final String name = secureData.getString("name");
backupData.setMnemonic(mnemonic);
backupData.setCreationTime(creationTime);
backupData.setName(name);
}