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


Java JSONObject.getBoolean方法代碼示例

本文整理匯總了Java中org.json.JSONObject.getBoolean方法的典型用法代碼示例。如果您正苦於以下問題:Java JSONObject.getBoolean方法的具體用法?Java JSONObject.getBoolean怎麽用?Java JSONObject.getBoolean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.json.JSONObject的用法示例。


在下文中一共展示了JSONObject.getBoolean方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parseArgs

import org.json.JSONObject; //導入方法依賴的package包/類
private void parseArgs(JSONArray args){
    Log.d(TAG,"Execute args: " + args.toString());
    if(args.length() > 0){
        try {
            final JSONObject obj = args.getJSONObject(0);
            _minTime = obj.getLong("minTime");
            _minDistance = obj.getLong("minDistance");
            _noWarn = obj.getBoolean("noWarn");
            _providers = obj.getString("providers");
            _useCache = obj.getBoolean("useCache");
            _returnSatelliteData = obj.getBoolean("satelliteData");
            _buffer = obj.getBoolean("buffer");
            _signalStrength = obj.getBoolean("signalStrength");
            _bufferSize = obj.getInt("bufferSize");

        }
        catch (Exception exc){
            Log.d(TAG, ErrorMessages.INCORRECT_CONFIG_ARGS + ", " + exc.getMessage());
            sendCallback(PluginResult.Status.ERROR, ErrorMessages.INCORRECT_CONFIG_ARGS + ", " + exc.getMessage());
        }
    }
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:23,代碼來源:AdvancedGeolocation.java

示例2: verify

import org.json.JSONObject; //導入方法依賴的package包/類
private void verify(JSONObject obj) throws JSONException {
	int ret = obj.getInt("ret");
	if (ret != 0) {
		showTip("��֤ʧ��");
		return;
	}
	if ("success".equals(obj.get("rst"))) {
		if (obj.getBoolean("verf")) {
			showTip("ͨ����֤����ӭ������");
			//�ش����ݣ���½�ɹ�
			Intent intent = new Intent();
			intent.putExtra("launch_return", 1);
			setResult(RESULT_OK,intent);
			//finish();
		} else {
			showTip("��֤��ͨ��");
		}
	} else {
		showTip("��֤ʧ��");
	}
}
 
開發者ID:JosephPai,項目名稱:WithYou,代碼行數:22,代碼來源:OnlineFace.java

示例3: buildAuthApplication

import org.json.JSONObject; //導入方法依賴的package包/類
public AuthApplication buildAuthApplication(JSONObject json) {
    String authId = json.getString("id");
    JSONObject app = json.getJSONObject("application");
    String id = app.getString("id");
    String name = app.getString("name");
    String icon = app.isNull("icon") ? null : app.getString("icon");
    String description = app.getString("description");

    boolean isPublicBot = app.has("bot_public") && app.getBoolean("bot_public");
    boolean requireCodeGrant = app.has("bot_require_code_grant") && app.getBoolean("bot_require_code_grant");

    JSONArray s = json.getJSONArray("scopes");
    List<Scope> scopes = new ArrayList<>();
    for (int i = 0; i < s.length(); i++) {
        scopes.add(Scope.getByKey(s.getString(i)));
    }

    return new AuthApplication(client, id, authId, name, icon, description, scopes, isPublicBot, requireCodeGrant);
}
 
開發者ID:AlienIdeology,項目名稱:J-Cord,代碼行數:20,代碼來源:ObjectBuilder.java

示例4: parseQnAJSON

import org.json.JSONObject; //導入方法依賴的package包/類
public static QnA parseQnAJSON(JSONObject rootJSONObject, int no) throws JSONException {
    String title = rootJSONObject.getString("title");
    String questionContent = rootJSONObject.getString("question_content");
    String questionDate = rootJSONObject.getString("question_date");
    String writer = rootJSONObject.getString("writer");
    boolean privacy = rootJSONObject.getBoolean("privacy");

    String answerContent = null;
    String answerDate = null;
    if (rootJSONObject.getBoolean("has_answer")) {
        answerContent = rootJSONObject.getString("answer_content");
        answerDate = rootJSONObject.getString("answer_date");
    }

    return new QnA(no, title, questionContent, questionDate,
            writer, answerContent, answerDate, privacy);
}
 
開發者ID:DSM-DMS,項目名稱:DMS,代碼行數:18,代碼來源:JSONParser.java

示例5: buildReaction

import org.json.JSONObject; //導入方法依賴的package包/類
public Reaction buildReaction(JSONObject json, Message message) {
    handleBuildError(json);
    int reactedTimes = json.has("count") ? json.getInt("count") : -1;
    boolean selfReacted = json.has("me") && json.getBoolean("me");

    Reaction reaction;
    JSONObject emojiJson = json.getJSONObject("emoji");

    /* Guild Emoji */
    if (emojiJson.has("id") && !emojiJson.isNull("id")) {
        IGuildEmoji emoji = message.getGuild().getGuildEmoji(emojiJson.getString("id"));
        if (emoji == null) { // Global Guild Emoji
            reaction = new Reaction(identity, message, reactedTimes, selfReacted, new GuildEmoji(identity, emojiJson.getString("id"), emojiJson.getString("name")));
        } else { // Guild Emoji
            reaction = new Reaction(identity, message, reactedTimes, selfReacted, emoji);
        }

    /* Emoji */
    } else {
        reaction = new Reaction(identity, message, reactedTimes, selfReacted, Emojis.getByUnicode(emojiJson.getString("name")));
    }
    return reaction;
}
 
開發者ID:AlienIdeology,項目名稱:J-Cord,代碼行數:24,代碼來源:ObjectBuilder.java

示例6: buildIntegration

import org.json.JSONObject; //導入方法依賴的package包/類
public Integration buildIntegration(JSONObject json) {
    handleBuildError(json);

    String id = json.getString("id");
    String name = json.getString("name");
    IConnection.Type type = IConnection.Type.getByKey(json.getString("type"));
    String lastSynced = json.getString("synced_at");
    boolean enabled = json.has("enabled") && json.getBoolean("enabled");
    boolean syncing = json.has("syncing") && json.getBoolean("syncing");

    Integration integration = new Integration(identity, id, name, type, lastSynced, enabled, syncing);

    /* User */
    IUser user = identity.getUser(json.getString("user"));
    integration.setUser(user);

    /* Account */
    JSONObject acc = json.getJSONObject("account");
    integration.setAccount(new IIntegration.Account(acc.getString("id"), acc.getString("name")));

    /* Role */
    IRole role = identity.getRole(json.getString("role_id"));
    integration.setRole(role);

    return integration;
}
 
開發者ID:AlienIdeology,項目名稱:J-Cord,代碼行數:27,代碼來源:ObjectBuilder.java

示例7: onSuccesAuth

import org.json.JSONObject; //導入方法依賴的package包/類
@Override
public void onSuccesAuth(JSONObject result) throws JSONException {

    progressDialog.hide();

    boolean getFlag = result.getBoolean("result");
    if (getFlag){
        startActivity(new Intent(this, StaffDeskActivity.class));
        overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
        SharedPreferences sharedpreferences = getSharedPreferences("staff", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedpreferences.edit();
        editor.putBoolean("login", true);
        editor.commit();
    }else{
        Toast.makeText(this, "Giriş Yapılamadı.", Toast.LENGTH_SHORT).show();
    }
}
 
開發者ID:yusufcakal,項目名稱:RestaurantApp,代碼行數:18,代碼來源:StaffLoginActivity.java

示例8: parseGoingoutApplyStatusJSON

import org.json.JSONObject; //導入方法依賴的package包/類
public static Goingout parseGoingoutApplyStatusJSON(JSONObject rootJSONObject)
        throws JSONException {

    boolean sat = rootJSONObject.getBoolean("sat");
    boolean sun = rootJSONObject.getBoolean("sun");

    return new Goingout(sat, sun);
}
 
開發者ID:DSM-DMS,項目名稱:DMS,代碼行數:9,代碼來源:JSONParser.java

示例9: testGetUsage

import org.json.JSONObject; //導入方法依賴的package包/類
public void testGetUsage() throws Exception
{
    RepoUsageStatus usageStatus = repoAdminService.getUsageStatus();
    RepoUsage usage = usageStatus.getUsage();
    LicenseDescriptor licenseDescriptor = descriptorService.getLicenseDescriptor();
    Date validUntil = (licenseDescriptor == null) ? null : licenseDescriptor.getValidUntil(); // might be null
    Integer checkLevel = new Integer(usageStatus.getLevel().ordinal());
    
    String url = "/api/admin/usage";
    TestWebScriptServer.GetRequest req = new TestWebScriptServer.GetRequest(url);
    
    Response response = sendRequest(req, Status.STATUS_OK, guest);
    System.out.println(response.getContentAsString());
    JSONObject json = new JSONObject(response.getContentAsString());
    Long users = json.isNull(AbstractAdminWebScript.JSON_KEY_USERS) ? null : json.getLong(AbstractAdminWebScript.JSON_KEY_USERS);
    assertEquals("Mismatched users", usage.getUsers(), users);
    Long documents = json.isNull(AbstractAdminWebScript.JSON_KEY_DOCUMENTS) ? null : json.getLong(AbstractAdminWebScript.JSON_KEY_DOCUMENTS);
    assertEquals("Mismatched documents", usage.getDocuments(), documents);
    String licenseMode = json.isNull(AbstractAdminWebScript.JSON_KEY_LICENSE_MODE) ? null : json.getString(AbstractAdminWebScript.JSON_KEY_LICENSE_MODE);
    assertEquals("Mismatched licenseMode", usage.getLicenseMode().toString(), licenseMode);
    boolean readOnly = json.getBoolean(AbstractAdminWebScript.JSON_KEY_READ_ONLY);
    assertEquals("Mismatched readOnly", usage.isReadOnly(), readOnly);
    boolean updated = json.getBoolean(AbstractAdminWebScript.JSON_KEY_UPDATED);
    assertEquals("Mismatched updated", false, updated);
    Long licenseValidUntil = json.isNull(AbstractAdminWebScript.JSON_KEY_LICENSE_VALID_UNTIL) ? null : json.getLong(AbstractAdminWebScript.JSON_KEY_LICENSE_VALID_UNTIL);
    assertEquals("Mismatched licenseValidUntil",
            (validUntil == null) ? null : validUntil.getTime(),
            licenseValidUntil);
    Integer level = json.isNull(AbstractAdminWebScript.JSON_KEY_LEVEL) ? null : json.getInt(AbstractAdminWebScript.JSON_KEY_LEVEL);
    assertEquals("Mismatched level", checkLevel, level);
    json.getJSONArray(AbstractAdminWebScript.JSON_KEY_WARNINGS);
    json.getJSONArray(AbstractAdminWebScript.JSON_KEY_ERRORS);
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:34,代碼來源:AdminWebScriptTest.java

示例10: handleSuccess

import org.json.JSONObject; //導入方法依賴的package包/類
@Override
protected void handleSuccess(JSONObject jsonObject)
        throws JSONException {
    if (jsonObject.getBoolean("success")) {
        issueResponseOnMainThread(null, uploadContext.videoId);
    } else {
        handleError(new FacebookException(ERROR_BAD_SERVER_RESPONSE));
    }
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:10,代碼來源:VideoUploader.java

示例11: RevenuePanelConfig

import org.json.JSONObject; //導入方法依賴的package包/類
public RevenuePanelConfig(JSONObject json) throws JSONException {
  try {
    showRevenuePanel = json.getBoolean(SHOW_REVENUE_PANEL);
  } catch (Exception e) {
    // ignore
  }
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:8,代碼來源:DashboardConfig.java

示例12: action

import org.json.JSONObject; //導入方法依賴的package包/類
public void action(final Event<JSONObject> event) throws EventException {
	final JSONObject data = event.getData();

	logger.debug("Processing an event[type={}, data={}] in listener[className={}]", event.getType(), data,
			RhythmArticleSender.class);
	try {
		final JSONObject originalArticle = data.getJSONObject(Article.ARTICLE);

		if (!originalArticle.getBoolean(Article.ARTICLE_IS_PUBLISHED)) {
			logger.debug("Ignores post article[title={}] to Rhythm",
					originalArticle.getString(Article.ARTICLE_TITLE));

			return;
		}

		final JSONObject preference = preferenceQueryService.getPreference();

		if (null == preference) {
			throw new EventException("Not found preference");
		}

		if (!StringUtils.isBlank(originalArticle.optString(Article.ARTICLE_VIEW_PWD))) {
			return;
		}

		if (Latkes.getServePath().contains("localhost")) {
			logger.info("Solo runs on local server, so should not send this article[id={}, title={}] to Rhythm",
					originalArticle.getString(Keys.OBJECT_ID), originalArticle.getString(Article.ARTICLE_TITLE));
			return;
		}

		final HTTPRequest httpRequest = new HTTPRequest();

		httpRequest.setURL(ADD_ARTICLE_URL);
		httpRequest.setRequestMethod(RequestMethod.POST);
		final JSONObject requestJSONObject = new JSONObject();
		final JSONObject article = new JSONObject();

		article.put(Keys.OBJECT_ID, originalArticle.getString(Keys.OBJECT_ID));
		article.put(Article.ARTICLE_TITLE, originalArticle.getString(Article.ARTICLE_TITLE));
		article.put(Article.ARTICLE_PERMALINK, originalArticle.getString(Article.ARTICLE_PERMALINK));
		article.put(Article.ARTICLE_TAGS_REF, originalArticle.getString(Article.ARTICLE_TAGS_REF));
		article.put(Article.ARTICLE_AUTHOR_EMAIL, originalArticle.getString(Article.ARTICLE_AUTHOR_EMAIL));
		article.put(Article.ARTICLE_CONTENT, originalArticle.getString(Article.ARTICLE_CONTENT));
		article.put(Article.ARTICLE_CREATE_DATE,
				((Date) originalArticle.get(Article.ARTICLE_CREATE_DATE)).getTime());
		article.put(Common.POST_TO_COMMUNITY, originalArticle.getBoolean(Common.POST_TO_COMMUNITY));

		// Removes this property avoid to persist
		originalArticle.remove(Common.POST_TO_COMMUNITY);

		requestJSONObject.put(Article.ARTICLE, article);
		requestJSONObject.put(Common.BLOG_VERSION, SoloConstant.VERSION);
		requestJSONObject.put(Common.BLOG, "B3log Solo");
		requestJSONObject.put(Option.ID_C_BLOG_TITLE, preference.getString(Option.ID_C_BLOG_TITLE));
		requestJSONObject.put("blogHost", Latkes.getServePath());
		requestJSONObject.put("userB3Key", preference.optString(Option.ID_C_KEY_OF_SOLO));
		requestJSONObject.put("clientAdminEmail", preference.optString(Option.ID_C_ADMIN_EMAIL));
		requestJSONObject.put("clientRuntimeEnv", Latkes.getRuntimeEnv().name());

		httpRequest.setPayload(requestJSONObject.toString().getBytes("UTF-8"));

		urlFetchService.fetchAsync(httpRequest);
	} catch (final Exception e) {
		logger.error("Sends an article to Rhythm error: {}", e.getMessage());
	}

	logger.debug("Sent an article to Rhythm");
}
 
開發者ID:daima,項目名稱:solo-spring,代碼行數:70,代碼來源:RhythmArticleSender.java

示例13: buildUser

import org.json.JSONObject; //導入方法依賴的package包/類
public User buildUser (JSONObject json) {
    handleBuildError(json);

    /* Basic Information */
    String id = json.has("webhook_id") ? json.getString("webhook_id") : json.getString("id");
    String name = json.getString("username");
    String discriminator = json.getString("discriminator");

    /* Require Email OAuth2 */
    String avatar = json.has("avatar") && !json.isNull("avatar") ? json.getString("avatar") : null;
    String email = json.has("email") && !json.isNull("email") ? json.getString("email") : null;

    /* Boolean Information */
    boolean isBot = json.has("bot") && json.getBoolean("bot");
    boolean isWebHook = json.has("webhook_id");
    boolean isVerified = json.has("verified") && json.getBoolean("verified");
    boolean isMFAEnabled = json.has("mfa_enabled") && json.getBoolean("mfa_enabled");

    User user = new User(identity, id)
            .setName(name)
            .setDiscriminator(discriminator)
            .setAvatar(avatar)
            .setEmail(email)
            .setBot(isBot)
            .setWebHook(isWebHook)
            .setVerified(isVerified)
            .setMFAEnabled(isMFAEnabled);

    identity.addUser(user);
    return user;
}
 
開發者ID:AlienIdeology,項目名稱:J-Cord,代碼行數:32,代碼來源:ObjectBuilder.java

示例14: action

import org.json.JSONObject; //導入方法依賴的package包/類
public void action(final Event<JSONObject> event) throws EventException {
	final JSONObject data = event.getData();

	logger.debug("Processing an event[type={}, data={}] in listener[className={}]", event.getType(), data,
			RhythmArticleUpdater.class);
	try {
		final JSONObject originalArticle = data.getJSONObject(Article.ARTICLE);

		if (!originalArticle.getBoolean(Article.ARTICLE_IS_PUBLISHED)) {
			logger.debug("Ignores post article[title={}] to Rhythm",
					originalArticle.getString(Article.ARTICLE_TITLE));

			return;
		}

		final JSONObject preference = preferenceQueryService.getPreference();

		if (null == preference) {
			throw new EventException("Not found preference");
		}

		if (!StringUtils.isBlank(originalArticle.optString(Article.ARTICLE_VIEW_PWD))) {
			return;
		}

		if (Latkes.getServePath().contains("localhost")) {
			logger.info("Solo runs on local server, so should not send this article[id={}, title={}] to Rhythm",
					originalArticle.getString(Keys.OBJECT_ID), originalArticle.getString(Article.ARTICLE_TITLE));
			return;
		}

		final HTTPRequest httpRequest = new HTTPRequest();

		httpRequest.setURL(UPDATE_ARTICLE_URL);
		httpRequest.setRequestMethod(RequestMethod.PUT);
		final JSONObject requestJSONObject = new JSONObject();
		final JSONObject article = new JSONObject();

		article.put(Keys.OBJECT_ID, originalArticle.getString(Keys.OBJECT_ID));
		article.put(Article.ARTICLE_TITLE, originalArticle.getString(Article.ARTICLE_TITLE));
		article.put(Article.ARTICLE_PERMALINK, originalArticle.getString(Article.ARTICLE_PERMALINK));
		article.put(Article.ARTICLE_TAGS_REF, originalArticle.getString(Article.ARTICLE_TAGS_REF));
		article.put(Article.ARTICLE_AUTHOR_EMAIL, originalArticle.getString(Article.ARTICLE_AUTHOR_EMAIL));
		article.put(Article.ARTICLE_CONTENT, originalArticle.getString(Article.ARTICLE_CONTENT));
		article.put(Article.ARTICLE_CREATE_DATE,
				((Date) originalArticle.get(Article.ARTICLE_CREATE_DATE)).getTime());
		article.put(Common.POST_TO_COMMUNITY, originalArticle.getBoolean(Common.POST_TO_COMMUNITY));

		// Removes this property avoid to persist
		originalArticle.remove(Common.POST_TO_COMMUNITY);

		requestJSONObject.put(Article.ARTICLE, article);
		requestJSONObject.put(Common.BLOG_VERSION, SoloConstant.VERSION);
		requestJSONObject.put(Common.BLOG, "B3log Solo");
		requestJSONObject.put(Option.ID_C_BLOG_TITLE, preference.getString(Option.ID_C_BLOG_TITLE));
		requestJSONObject.put("blogHost", Latkes.getServerHost() + ":" + Latkes.getServerPort());
		requestJSONObject.put("userB3Key", preference.optString(Option.ID_C_KEY_OF_SOLO));
		requestJSONObject.put("clientAdminEmail", preference.optString(Option.ID_C_ADMIN_EMAIL));
		requestJSONObject.put("clientRuntimeEnv", Latkes.getRuntimeEnv().name());

		httpRequest.setPayload(requestJSONObject.toString().getBytes("UTF-8"));

		urlFetchService.fetchAsync(httpRequest);
	} catch (final Exception e) {
		logger.error("Sends an article to Rhythm error: {}", e.getMessage());
	}

	logger.debug("Sent an article to Rhythm");
}
 
開發者ID:daima,項目名稱:solo-spring,代碼行數:70,代碼來源:RhythmArticleUpdater.java

示例15: loadGlobalReasonAssignments

import org.json.JSONObject; //導入方法依賴的package包/類
public static SortedMap<String, SortedSet<SingleWorkerAssignment<JSONArray>>> loadGlobalReasonAssignments(
        File mTurkOutputCSVFile)
        throws Exception
{
    MTurkOutputReader outputReader = new MTurkOutputReader(false, mTurkOutputCSVFile);

    // argId, set of assignments -- the json array is a list of annotated segments
    SortedMap<String, SortedSet<SingleWorkerAssignment<JSONArray>>> globalReasonAssignments = new TreeMap<>();

    for (Map<String, String> row : outputReader) {

        String workerId = row.get("workerid");
        SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM d HH:mm:ss zzz yyyy",
                Locale.ENGLISH);
        Date time = dateFormat.parse(row.get("assignmentaccepttime"));

        // claims
        String jsonResults = row.get("Answer.collectedAnnotationResults");

        JSONObject jsonObject = new JSONObject(jsonResults);

        // iterate over argIDs
        for (Object argIdObject : jsonObject.keySet()) {
            String argId = argIdObject.toString();
            JSONObject argumentJsonAnnotations = jsonObject.getJSONObject(argId);
            JSONArray segments = argumentJsonAnnotations.getJSONArray("segments");

            // we don't need this one in fact...
            boolean noReasons = argumentJsonAnnotations.getBoolean("noReasons");

            SingleWorkerAssignment<JSONArray> singleWorkerAssignment = new SingleWorkerAssignment<>(
                    workerId, time, segments);

            // update the global map
            if (!globalReasonAssignments.containsKey(argId)) {
                globalReasonAssignments
                        .put(argId, new TreeSet<SingleWorkerAssignment<JSONArray>>());
            }
            globalReasonAssignments.get(argId).add(singleWorkerAssignment);
        }
    }
    return globalReasonAssignments;
}
 
開發者ID:UKPLab,項目名稱:argument-reasoning-comprehension-task,代碼行數:44,代碼來源:Step2bGoldReasonAnnotator.java


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