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


Java JsonObject.isJsonNull方法代碼示例

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


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

示例1: overrideDefaultSettings

import com.google.gson.JsonObject; //導入方法依賴的package包/類
/**
 * Overrides default setting with the settings fetched fron the community.
 *
 * @param clientSettings    Local settings to be used.
 * @param serverSettingJson Settings received from community.
 */
private static void overrideDefaultSettings(JsonObject clientSettings, JsonObject serverSettingJson) {
    if (serverSettingJson != null && !serverSettingJson.isJsonNull()) {
        if (serverSettingJson.has("response_limit")) {
            int limit = serverSettingJson.get("response_limit").getAsInt();
            clientSettings.addProperty("limit", limit);
        }

        if (serverSettingJson.has("discussion_style")) {
            JsonArray discussionStyleArr = serverSettingJson.get("discussion_style").getAsJsonArray();
            StringBuilder conversationStyleSB = new StringBuilder();
            boolean isFirst = true;
            conversationStyleSB.append("(");
            for (JsonElement styleElem : discussionStyleArr) {
                if (isFirst) {
                    isFirst = false;
                } else {
                    conversationStyleSB.append(", ");
                }
                conversationStyleSB.append("'").append(styleElem.getAsString()).append("'");
            }
            conversationStyleSB.append(")");
            if (clientSettings.has("whereClauses")) {
                JsonArray whereArr = clientSettings.get("whereClauses").getAsJsonArray();
                for (JsonElement whereElem : whereArr) {
                    JsonObject whereObj = whereElem.getAsJsonObject();
                    if (whereObj.has("key")) {
                        String key = whereObj.get("key").getAsString();
                        if (key.equals("conversation.style")) {
                            whereObj.addProperty("value", conversationStyleSB.toString());
                        }
                    }
                }
            }
        }
    }
}
 
開發者ID:lithiumtech,項目名稱:li-android-sdk-core,代碼行數:43,代碼來源:LiQueryBuilder.java

示例2: checkInitialParametersForCommandExecution

import com.google.gson.JsonObject; //導入方法依賴的package包/類
/**
 * This function is used to check if all the initial parameters are set for the execution of the
 * {@codeEvaluateAlgorithmsCommand}.
 * 
 * @throws CommandCannotBeExecutedException if the initial parameters are not set for the
 *            execution of the command
 */
private void checkInitialParametersForCommandExecution() throws CommandCannotBeExecutedException {
   if (eLearningProblem == null) {
      canBeExecuted = false;
      throw new CommandCannotBeExecutedException(LEARNING_PROBLEM_NOTSET_ERROR_MESSAGE);
   }
   JsonObject evaluationConfigurationJsonObject = systemConfiguration.getJsonEvaluationConfiguration();
   JsonElement evaluationName = null;
   JsonElement evaluationMetrics = null;
   if (evaluationConfigurationJsonObject.isJsonNull()) {
      logger.warn(EVALUATION_JSONSTRING_NOTSET_WARNING_MESSAGE);

   } else {
      evaluationName = evaluationConfigurationJsonObject.get(EvaluationsKeyValuePairs.EVALUATION_NAME);
      evaluationMetrics = evaluationConfigurationJsonObject.get(EvaluationsKeyValuePairs.EVALUATION_METRIC_ARRAY_IDENTIFIER);
   }
   if (evaluationIdentifier.isEmpty() && evaluationName == null) {
      canBeExecuted = false;
      String errorMessage = String.format(EVALUATION_IDENTIFIER_NOTSET_ERROR_MESSAGE, eLearningProblem.getLearningProblemIdentifier());
      throw new CommandCannotBeExecutedException(errorMessage);
   }
   if (metricIdentifiers.isEmpty() && evaluationMetrics == null) {
      logger.warn(EVALUATION_METRIC_IDENTIFIER_NOTSET_WARNING_MESSAGE);
   }

}
 
開發者ID:Intelligent-Systems-Group,項目名稱:jpl-framework,代碼行數:33,代碼來源:EvaluateAlgorithmsCommand.java

示例3: buildSlackUser

import com.google.gson.JsonObject; //導入方法依賴的package包/類
static final SlackUser buildSlackUser(JsonObject jsonUser)
{
    String id = GsonHelper.getStringOrNull(jsonUser.get("id"));
    String name = GsonHelper.getStringOrNull(jsonUser.get("name"));
    String realName = GsonHelper.getStringOrNull(jsonUser.get("real_name"));
    String tz = GsonHelper.getStringOrNull(jsonUser.get("tz"));
    String tzLabel = GsonHelper.getStringOrNull(jsonUser.get("tz_label"));
    JsonElement element = jsonUser.get("tz_offset");
    Integer tzOffset = null;
    if (element != null)
    {
        tzOffset = element.getAsInt();
    }
    Boolean deleted = GsonHelper.ifNullFalse(jsonUser.get("deleted"));
    Boolean admin = GsonHelper.ifNullFalse(jsonUser.get("is_admin"));
    Boolean owner = GsonHelper.ifNullFalse(jsonUser.get("is_owner"));
    Boolean primaryOwner = GsonHelper.ifNullFalse(jsonUser.get("is_primary_owner"));
    Boolean restricted = GsonHelper.ifNullFalse(jsonUser.get("is_restricted"));
    Boolean ultraRestricted = GsonHelper.ifNullFalse(jsonUser.get("is_ultra_restricted"));
    Boolean bot = GsonHelper.ifNullFalse(jsonUser.get("is_bot"));
    JsonObject profileJSON = GsonHelper.getJsonObjectOrNull(jsonUser.get("profile"));
    String email = "";
    String skype = "";
    String title = "";
    String phone = "";
    String presence = "";
    if (profileJSON !=null && !profileJSON.isJsonNull())
    {
        email = GsonHelper.getStringOrNull(profileJSON.get("email"));
        skype = GsonHelper.getStringOrNull(profileJSON.get("skype"));
        title = GsonHelper.getStringOrNull(profileJSON.get("title"));
        phone = GsonHelper.getStringOrNull(profileJSON.get("phone"));
        presence = GsonHelper.getStringOrNull(profileJSON.get("presence"));
    }
    SlackPersona.SlackPresence slackPresence = SlackPersona.SlackPresence.UNKNOWN;
    if ("active".equals(presence))
    {
        slackPresence = SlackPersona.SlackPresence.ACTIVE;
    }
    if ("away".equals(presence))
    {
        slackPresence = SlackPersona.SlackPresence.AWAY;
    }
    return new SlackUserImpl(id, name, realName, email, skype, title, phone, deleted, admin, owner, primaryOwner, restricted, ultraRestricted, bot, tz, tzLabel, tzOffset == null ? null : new Integer(tzOffset.intValue()), slackPresence);
}
 
開發者ID:riversun,項目名稱:slacklet,代碼行數:46,代碼來源:SlackJSONParsingUtils.java


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