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


Java JSONObject.getLong方法代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:ChessCom,項目名稱:android-chessclock,代碼行數:17,代碼來源:TimeControlParser.java

示例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);
}
 
開發者ID:TheMonitorLizard,項目名稱:BalloonBoat,代碼行數:22,代碼來源:Bot.java

示例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;
}
 
開發者ID:pre-dem,項目名稱:pre-dem-android,代碼行數:25,代碼來源:PrintLogger.java

示例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;
}
 
開發者ID:AlienIdeology,項目名稱:J-Cord,代碼行數:20,代碼來源:ObjectBuilder.java

示例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)));
    }
}
 
開發者ID:devgianlu,項目名稱:PlayConsoleAndroidAPI,代碼行數:22,代碼來源:Notification.java

示例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);
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:22,代碼來源:DownloadDBBean.java

示例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"));
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:17,代碼來源:SolrStatsResult.java

示例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;
    }
}
 
開發者ID:AyushR1,項目名稱:KernelAdiutor-Mod,代碼行數:32,代碼來源:DeviceInfo.java

示例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");
}
 
開發者ID:mkotb,項目名稱:Reddigram,代碼行數:8,代碼來源:LiveUpdate.java

示例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;
}
 
開發者ID:Ray-Eldath,項目名稱:Avalon-GroupCleaner,代碼行數:11,代碼來源:CoolQGroupOperator.java

示例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;
}
 
開發者ID:lvaccaro,項目名稱:BitcoinBlockExplorer,代碼行數:11,代碼來源:ValueOut.java

示例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;
    }
}
 
開發者ID:devgianlu,項目名稱:PlayConsoleAndroidAPI,代碼行數:37,代碼來源:ReleaseTracksSummary.java

示例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;
    }
}
 
開發者ID:customerly,項目名稱:Customerly-Android-SDK,代碼行數:11,代碼來源:IE_Admin.java

示例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;
}
 
開發者ID:rtr-nettest,項目名稱:open-rmbt,代碼行數:38,代碼來源:HstoreParser.java

示例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);

	}
 
開發者ID:uniquid,項目名稱:uniquid-utils,代碼行數:12,代碼來源:SeedUtils.java


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