本文整理汇总了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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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");
}
}
示例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;
}
示例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);
}
}
示例9: fromJson
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public Boolean fromJson(JsonNode json) {
return json.isBoolean() ? json.booleanValue() : null;
}
示例10: convert
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public Object convert(Schema schema, JsonNode value) {
return value.booleanValue();
}