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