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; }
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();
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();
private JsonNode getSchema(String schemaName, JsonNode models) { return models.findPath(schemaName); }
public JsonNode getDocAsNode() { return node.findPath(DOC_FIELD_NAME); }
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; }
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; }
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); } }
@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(); } }
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); } }
@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(); } }
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); }
private boolean checkReason(String expect) { if (body == null) { return false; } JsonNode reason = body.findPath("reason"); return !reason.isMissingNode() ? reason.textValue().equals(expect) : false; }
protected boolean isOk(SlackMethod method) { JsonNode retNode = call(method); return retNode.findPath("ok").asBoolean(); }
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 } }
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); }
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)); }