当前位置: 首页>>代码示例>>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;未经允许,请勿转载。