本文整理了Java中com.fasterxml.jackson.databind.JsonNode.findPath()
方法的一些代码示例,展示了JsonNode.findPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.findPath()
方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.JsonNode
类名称:JsonNode
方法名:findPath
[英]Method similar to #findValue, but that will return a "missing node" instead of null if no field is found. Missing node is a specific kind of node for which #isMissingNodereturns true; and all value access methods return empty or missing value.
[中]方法类似于#findValue,但如果未找到字段,则将返回“缺少节点”而不是null。缺失节点是#IsMissingNodeRe为真的特定类型的节点;所有值访问方法都返回空值或缺少值。
代码示例来源:origin: liferay/liferay-portal
private Map<String, String> _getJsonHomeRootEndpointMap(JsonNode jsonNode) {
Map<String, String> resourcesMap = new TreeMap<>();
JsonNode resourcesJsonNode = jsonNode.findPath(
JSONLDConstants.RESOURCES);
Iterator<String> fieldNames = resourcesJsonNode.fieldNames();
while (fieldNames.hasNext()) {
String fieldName = fieldNames.next();
JsonNode fieldValue = resourcesJsonNode.get(fieldName);
if (fieldValue.has(JSONLDConstants.HREF)) {
JsonNode hrefJsonNode = fieldValue.get(JSONLDConstants.HREF);
resourcesMap.put(hrefJsonNode.asText(), fieldName);
}
}
return resourcesMap;
}
代码示例来源:origin: apache/nifi
if (flowFilesToTransfer.size() > i) {
FlowFile flowFile = flowFilesToTransfer.remove(i);
int status = itemNode.findPath("status").asInt();
if (!isSuccess(status)) {
if (errorReason == null) {
String reason = itemNode.findPath("result").asText();
if (StringUtils.isEmpty(reason)) {
reason = itemNode.findPath("reason").asText();
代码示例来源:origin: apache/nifi
for (int i = itemNodeArray.size() - 1; i >= 0; i--) {
JsonNode itemNode = itemNodeArray.get(i);
int status = itemNode.findPath("status").asInt();
if (!isSuccess(status)) {
if (errorReason == null) {
String reason = itemNode.findPath("result").asText();
if (StringUtils.isEmpty(reason)) {
reason = itemNode.findPath("reason").asText();
代码示例来源:origin: amazon-archives/aws-apigateway-importer
private JsonNode getSchema(String schemaName, JsonNode models) {
return models.findPath(schemaName);
}
代码示例来源:origin: helun/Ektorp
public JsonNode getDocAsNode() {
return node.findPath(DOC_FIELD_NAME);
}
代码示例来源:origin: stackoverflow.com
JsonNode readTree = mapper.readTree(body);
for (JsonNode node : readTree.findPath("items")) {
System.out.println(node.findPath("images").get(2));
System.out.println(node.findPath("preview_url"));
}
代码示例来源:origin: spring-cloud/spring-cloud-aws
private static MediaType getMediaType(JsonNode content) {
JsonNode contentTypeNode = content.findPath("MessageAttributes").findPath("contentType");
if (contentTypeNode.isObject()) {
String contentType = contentTypeNode.findPath("Value").asText();
if (StringUtils.hasText(contentType)) {
return MediaType.parseMediaType(contentType);
}
}
return MediaType.TEXT_PLAIN;
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-aws-messaging
private static MediaType getMediaType(JsonNode content) {
JsonNode contentTypeNode = content.findPath("MessageAttributes").findPath("contentType");
if (contentTypeNode.isObject()) {
String contentType = contentTypeNode.findPath("Value").asText();
if (StringUtils.hasText(contentType)) {
return MediaType.parseMediaType(contentType);
}
}
return MediaType.TEXT_PLAIN;
}
代码示例来源:origin: allbegray/slack-api
protected <T> T readValue(JsonNode node, String findPath, TypeReference<?> typeReference) {
try {
if (findPath != null) {
if (!node.has(findPath)) return null;
node = node.findPath(findPath);
}
return mapper.readValue(node.toString(), typeReference);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: spring-cloud/spring-cloud-aws
@Override
protected Object doResolveArgumentFromNotificationMessage(JsonNode content, HttpInputMessage request, Class<?> parameterType) {
if (!"Notification".equals(content.get("Type").asText())) {
throw new IllegalArgumentException("@NotificationMessage annotated parameters are only allowed for method that receive a notification message.");
}
return content.findPath("Subject").asText();
}
}
代码示例来源:origin: allbegray/slack-api
protected <T> T readValue(JsonNode node, String findPath, Class<T> valueType) {
try {
if (findPath != null) {
if (!node.has(findPath)) return null;
node = node.findPath(findPath);
}
return mapper.readValue(node.toString(), valueType);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-aws-messaging
@Override
protected Object doResolveArgumentFromNotificationMessage(JsonNode content, HttpInputMessage request, Class<?> parameterType) {
if (!"Notification".equals(content.get("Type").asText())) {
throw new IllegalArgumentException("@NotificationMessage annotated parameters are only allowed for method that receive a notification message.");
}
return content.findPath("Subject").asText();
}
}
代码示例来源:origin: allbegray/slack-api
@Override
public String openDirectMessageChannel(String user) {
JsonNode retNode = call(new ImOpenMethod(user));
return retNode.findPath("channel").findPath("id").asText();
}
代码示例来源:origin: stackoverflow.com
final String placesResponse = "...";
final ObjectMapper om;
NearbyPlace place = null;
final JsonNode placesNode = om.readTree(placesResponse);
final JsonNode locationNode = placesNode.findPath("geometry").findPath("location");
if (! locationNode.isMissingNode()) {
place = om.treeToValue(locationNode, NearbyPlace.class);
}
代码示例来源:origin: helun/Ektorp
private boolean checkReason(String expect) {
if (body == null) {
return false;
}
JsonNode reason = body.findPath("reason");
return !reason.isMissingNode() ? reason.textValue().equals(expect) : false;
}
代码示例来源:origin: allbegray/slack-api
protected boolean isOk(SlackMethod method) {
JsonNode retNode = call(method);
return retNode.findPath("ok").asBoolean();
}
代码示例来源:origin: stackoverflow.com
JsonNode json = request().body().asJson();
Logger.info("JSON : " + json.findPath("in").findPath("id"));
Logger.info("JSON : " + json.findValues("in"));
List<JsonNode> ins = new org.json.simple.JSONArray();
ins = json.findValues("in");
for (final JsonNode objNode : ins) {
for (final JsonNode element : objNode) {
Logger.info(">>>>>" + element.findPath("id"));
//create my object for database
}
}
代码示例来源:origin: allbegray/slack-api
public static SlackRealTimeMessagingClient createSlackRealTimeMessagingClient(String token, ObjectMapper mapper, ProxyServerInfo proxyServerInfo) {
SlackWebApiClient webApiClient = createWebApiClient(token, proxyServerInfo);
String webSocketUrl = webApiClient.startRealTimeMessagingApi().findPath("url").asText();
return new SlackRealTimeMessagingClient(webSocketUrl, mapper, proxyServerInfo);
}
代码示例来源:origin: apache/asterixdb
private void deleteNCTxnLogs(String nodeId, CompilationUnit cUnit) throws Exception {
OutputFormat fmt = OutputFormat.forCompilationUnit(cUnit);
String endpoint = "/admin/cluster/node/" + nodeId + "/config";
InputStream executeJSONGet = executeJSONGet(fmt, createEndpointURI(endpoint, null));
StringWriter actual = new StringWriter();
IOUtils.copy(executeJSONGet, actual, StandardCharsets.UTF_8);
String config = actual.toString();
ObjectMapper om = new ObjectMapper();
String logDir = om.readTree(config).findPath("txn.log.dir").asText();
FileUtils.deleteQuietly(new File(logDir));
}
代码示例来源:origin: marklogic/java-client-api
private ArrayNode executeAndExtractBindings(SPARQLQueryDefinition qdef) {
JacksonHandle handle = smgr.executeSelect(qdef, new JacksonHandle());
JsonNode results = handle.get();
ArrayNode bindings = (ArrayNode) results.findPath("results").findPath(
"bindings");
return bindings;
}
内容来源于网络,如有侵权,请联系作者删除!