当前位置: 首页>>代码示例>>Java>>正文


Java JsonNode.booleanValue方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.JsonNode.booleanValue方法的典型用法代码示例。如果您正苦于以下问题:Java JsonNode.booleanValue方法的具体用法?Java JsonNode.booleanValue怎么用?Java JsonNode.booleanValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.databind.JsonNode的用法示例。


在下文中一共展示了JsonNode.booleanValue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: asValue

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public Object asValue(Object object) {
    ObjectMapper objectMapper = getObjectMapper();
    JsonNode node = objectMapper.convertValue(object, JsonNode.class);
    if (node == null) {
        return null;
    }

    switch (node.getNodeType()) {
        case NUMBER:
            return node.numberValue();
        case STRING:
            return node.textValue();
        case BOOLEAN:
            return node.booleanValue();
        case ARRAY:
        case BINARY:
        case MISSING:
        case NULL:
        case OBJECT:
        case POJO:
        default:
            return null;
    }
}
 
开发者ID:dizitart,项目名称:nitrite-database,代码行数:26,代码来源:JacksonMapper.java

示例2: getElement

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Return the field with name in JSON as a string, a boolean, a number or a node.
 *
 * @param json json
 * @param name node name
 * @return the field
 */
public static Object getElement(final JsonNode json, final String name) {
    if (json != null && name != null) {
        JsonNode node = json;
        for (String nodeName : name.split("\\.")) {
            if (node != null) {
                node = node.get(nodeName);
            }
        }
        if (node != null) {
            if (node.isNumber()) {
                return node.numberValue();
            } else if (node.isBoolean()) {
                return node.booleanValue();
            } else if (node.isTextual()) {
                return node.textValue();
            } else if (node.isNull()) {
                return null;
            } else {
                return node;
            }
        }
    }
    return null;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:32,代码来源:JsonHelper.java

示例3: isSetTo

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
default boolean isSetTo(String annotation, boolean testval) {
    JsonNode node = getAnnotations().get(annotation);
    if (node != null) {
        return node.isBoolean() && node.booleanValue() == testval;
    }
    return false;
}
 
开发者ID:atlascon,项目名称:travny,代码行数:8,代码来源:Annotable.java

示例4: loadObject

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private Object loadObject(JsonNode node) {
    if (node == null) return null;
    try {
        switch (node.getNodeType()) {
            case ARRAY:
                return loadArray(node);
            case BINARY:
                return node.binaryValue();
            case BOOLEAN:
                return node.booleanValue();
            case MISSING:
            case NULL:
                return null;
            case NUMBER:
                return node.numberValue();
            case OBJECT:
                return loadDocument(node);
            case POJO:
                return loadDocument(node);
            case STRING:
                return node.textValue();
        }
    } catch (IOException e) {
        return null;
    }
    return null;
}
 
开发者ID:dizitart,项目名称:nitrite-database,代码行数:28,代码来源:JacksonMapper.java

示例5: fromJson

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public Object fromJson(JsonNode json) {
	if (json.isTextual()) {
		return json.textValue();
	} else if (json.isNumber()) {
		return json.numberValue();
	} else if (json.isBoolean()) {
		return json.booleanValue();
	} else {
		return null;
	}
}
 
开发者ID:networknt,项目名称:openapi-parser,代码行数:13,代码来源:PrimitiveOverlay.java

示例6: getValue

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private Object getValue(JsonNode node) {
	if (node.isNumber()) {
		return node.numberValue();
	} else if (node.isTextual()) {
		return node.textValue();
	} else if (node.isBoolean()) {
		return node.booleanValue();
	} else if (node.isNull()) {
		return null;
	} else {
		throw new IllegalArgumentException("Non-value JSON node got through value node filter");
	}
}
 
开发者ID:networknt,项目名称:openapi-parser,代码行数:14,代码来源:BigParseTest.java

示例7: decodeJson

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private static Object decodeJson(String value) {
  int pos = 0;
  while (pos < value.length() && Character.isWhitespace(value.charAt(pos))) {
    pos++;
  }
  if (pos == value.length()) {
    return null;
  } else if (value.charAt(pos) == '{') {
    return new JsonObject(value);
  } else if (value.charAt(pos) == '[') {
    return new JsonArray(value);
  } else {
    try {
      JsonNode jsonNode = Json.mapper.readTree(value);
      if (jsonNode.isNumber()) {
        return jsonNode.numberValue();
      } else if (jsonNode.isBoolean()) {
        return jsonNode.booleanValue();
      } else if (jsonNode.isTextual()) {
        return jsonNode.textValue();
      }
    } catch (IOException e) {
      // do nothing
    }
  }
  return null;
}
 
开发者ID:vietj,项目名称:reactive-pg-client,代码行数:28,代码来源:DataType.java

示例8: triggerJenkinsWebHook

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Triggers the given jenkins job via its URL.
 *
 * @param authHeader
 * @param jobUrl     the URL to the jenkins job
 * @param triggerUrl can be null or empty and the default triggerUrl will be used
 */
protected void triggerJenkinsWebHook(String token, String authHeader, String jobUrl, String triggerUrl, boolean post) {
    if (Strings.isNullOrBlank(triggerUrl)) {
        //triggerUrl = URLUtils.pathJoin(jobUrl, "/build?token=" + token);
        triggerUrl = URLUtils.pathJoin(jobUrl, "/build?delay=0");
    }
    // lets check if this build is already running in which case do nothing
    String lastBuild = URLUtils.pathJoin(jobUrl, "/lastBuild/api/json");
    JsonNode lastBuildJson = parseLastBuildJson(authHeader, lastBuild);
    JsonNode building = null;
    if (lastBuildJson != null && lastBuildJson.isObject()) {
        building = lastBuildJson.get("building");
        if (building != null && building.isBoolean()) {
            if (building.booleanValue()) {
                LOG.info("Build is already running so lets not trigger another one!");
                return;
            }
        }
    }
    LOG.info("Got last build JSON: " + lastBuildJson + " building: " + building);

    LOG.info("Triggering Jenkins build: " + triggerUrl);

    Client client = WebClientHelpers.createClientWihtoutHostVerification();
    try {
        Response response = client.target(triggerUrl).
                request().
                header("Authorization", authHeader).
                post(Entity.text(null), Response.class);

        int status = response.getStatus();
        String message = null;
        Response.StatusType statusInfo = response.getStatusInfo();
        if (statusInfo != null) {
            message = statusInfo.getReasonPhrase();
        }
        String extra = "";
        if (status == 302) {
            extra = " Location: " + response.getLocation();
        }
        LOG.info("Got response code from Jenkins: " + status + " message: " + message + " from URL: " + triggerUrl + extra);
        if (status <= 200 || status > 302) {
            LOG.error("Failed to trigger job " + triggerUrl + ". Status: " + status + " message: " + message);
        }
    } finally {
        closeQuietly(client);
    }
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:55,代码来源:CreateBuildConfigStep.java

示例9: fromJson

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public Boolean fromJson(JsonNode json) {
	return json.isBoolean() ? json.booleanValue() : null;
}
 
开发者ID:networknt,项目名称:openapi-parser,代码行数:5,代码来源:BooleanOverlay.java

示例10: convert

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public Object convert(Schema schema, JsonNode value) {
    return value.booleanValue();
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:5,代码来源:JsonConverter.java


注:本文中的com.fasterxml.jackson.databind.JsonNode.booleanValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。