當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。