Refine search
public Set<String> getClosedIndices(final Collection<String> indices) { final JsonNode catIndices = catIndices(indices, "index", "status"); final ImmutableSet.Builder<String> closedIndices = ImmutableSet.builder(); for (JsonNode jsonElement : catIndices) { if (jsonElement.isObject()) { final String index = jsonElement.path("index").asText(null); final String status = jsonElement.path("status").asText(null); if (index != null && "close".equals(status)) { closedIndices.add(index); } } } return closedIndices.build(); }
private ObjectNode arraySchema(JsonNode exampleArray) { ObjectNode schema = this.objectMapper.createObjectNode(); schema.put("type", "array"); if (exampleArray.size() > 0) { JsonNode exampleItem = exampleArray.get(0).isObject() ? mergeArrayItems(exampleArray) : exampleArray.get(0); schema.set("items", schemaFromExample(exampleItem)); } return schema; }
policyNode = Jackson.jsonNodeOf(jsonString); idNode = policyNode.get(JsonDocumentFields.POLICY_ID); if (isNotNull(idNode)) { policy.setId(idNode.asText()); statementsNode = policyNode.get(JsonDocumentFields.STATEMENT); if (isNotNull(statementsNode)) { if (statementsNode.isObject()) { statements.add(statementOf(statementsNode)); } else if (statementsNode.isArray()) { for (JsonNode statementNode : statementsNode) { statements.add(statementOf(statementNode));
@Override public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); if (node.isTextual()) { return node.textValue(); } else if (node.isObject()) { JsonNode allNode = node.get("__all__"); if (allNode != null && allNode.isArray()) { StringBuilder buf = new StringBuilder(); for (JsonNode msgNode : allNode) { buf.append(msgNode.textValue()); buf.append(","); } return buf.length() > 0 ? buf.substring(0, buf.length() - 1) : buf.toString(); } return node.toString(); } return null; } }
private Object extractBody(ClientResponse cr) { String json = cr.getEntity(String.class); logger.info(json); try { JsonNode node = om.readTree(json); if (node.isArray()) { return om.convertValue(node, listOfObj); } else if (node.isObject()) { return om.convertValue(node, mapOfObj); } else if (node.isNumber()) { return om.convertValue(node, Double.class); } else { return node.asText(); } } catch (IOException jpe) { logger.error(jpe.getMessage(), jpe); return json; } }
public static void printAll(JsonNode node) { Iterator<String> fieldNames = node.getFieldNames(); while(fieldNames.hasNext()){ String fieldName = fieldNames.next(); JsonNode fieldValue = node.get(fieldName); if (fieldValue.isObject()) { System.out.println(fieldName + " :"); printAll(fieldValue); } else { String value = fieldValue.asText(); System.out.println(fieldName + " : " + value); } } }
String propertySetName = entry.getKey(); JsonNode value = entry.getValue(); if (value.isObject()) { ObjectNode set = (ObjectNode)value; Iterator<Entry<String, JsonNode>> propertySetFields = set.fields(); queryPart.addProperty(propertySetName, propertyEntry.getKey(), propertyValue.asDouble()); } else if (propertyValue.getNodeType() == JsonNodeType.STRING) { queryPart.addProperty(propertySetName, propertyEntry.getKey(), propertyValue.asText()); } else if (propertyValue.getNodeType() == JsonNodeType.NULL) { queryPart.addProperty(propertySetName, propertyEntry.getKey(), null);
if (schema == null || schema.getType().equals(Schema.Type.STRING) || schema.getType().equals(Schema.Type.ENUM)) { return jsonNode.asText(); } else if (schema.getType().equals(Schema.Type.BYTES) || schema.getType().equals(Schema.Type.FIXED)) { return jsonNode.textValue().getBytes(StandardCharsets.ISO_8859_1); } else if (jsonNode.isArray()) { List l = new ArrayList(); for (JsonNode node : jsonNode) { } else if (jsonNode.isObject()) { Map m = new LinkedHashMap(); for (Iterator<String> it = jsonNode.fieldNames(); it.hasNext(); ) { s = schema.getField(key).schema(); Object value = toObject(jsonNode.get(key), s); m.put(key, value);
@Override public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); if (node.isTextual()) { return node.textValue(); } else if (node.isObject()) { JsonNode allNode = node.get("__all__"); if (allNode != null && allNode.isArray()) { StringBuffer buf = new StringBuffer(); for (JsonNode msgNode : allNode) { buf.append(msgNode.textValue()); buf.append(","); } return buf.length() > 0 ? buf.substring(0, buf.length() - 1) : buf.toString(); } return node.toString(); } return null; } }
@JsonSetter("comment") public void setComment(JsonNode jsonNode) { if (jsonNode.isObject()) { try { this.comment = new ObjectMapper().treeToValue(jsonNode, Comment.class); } catch (JsonProcessingException e) { logger.error("Error deserializing json: ", e); } } else if (jsonNode.isTextual()) { this.commentId = jsonNode.asText(); } }
@Override public CoinMarketCapQuote deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { ObjectCodec oc = jp.getCodec(); JsonNode node = oc.readTree(jp); if (node.isObject()) { BigDecimal price = new BigDecimal(node.get("price").asDouble()); BigDecimal volume24h = new BigDecimal(node.get("volume_24h").asDouble()); BigDecimal marketCap = new BigDecimal(node.get("market_cap").asDouble()); // TODO use these to create CoinMarketCapHistoricalSpotPrice instances BigDecimal pctChange1h = new BigDecimal(node.get("percent_change_1h").asDouble()); BigDecimal pctChange24h = new BigDecimal(node.get("percent_change_24h").asDouble()); BigDecimal pctChange7d = new BigDecimal(node.get("percent_change_7d").asDouble()); return new CoinMarketCapQuote( price, volume24h, marketCap, pctChange1h, pctChange24h, pctChange7d); } return null; } }
JsonNode routingDefaultsNode = config.get("routingDefaults"); if (routingDefaultsNode != null) { LOG.info("Loading default routing parameters from JSON:"); JsonNode timeout = config.get("timeout"); if (timeout != null) { if (timeout.isNumber()) { JsonNode timeouts = config.get("timeouts"); if (timeouts != null) { if (timeouts.isArray() && timeouts.size() > 0) { this.timeouts = new double[timeouts.size()]; int i = 0; JsonNode boardTimes = config.get("boardTimes"); if (boardTimes != null && boardTimes.isObject()) { graph.boardTimes = new EnumMap<>(TraverseMode.class); for (TraverseMode mode : TraverseMode.values()) { JsonNode alightTimes = config.get("alightTimes"); if (alightTimes != null && alightTimes.isObject()) { graph.alightTimes = new EnumMap<>(TraverseMode.class); for (TraverseMode mode : TraverseMode.values()) {
@Override public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); if (node.isTextual()) { return node.textValue(); } else if (node.isObject()) { JsonNode allNode = node.get("__all__"); if (allNode != null && allNode.isArray()) { StringBuffer buf = new StringBuffer(); for (JsonNode msgNode : allNode) { buf.append(msgNode.textValue()); buf.append(","); } return buf.length() > 0 ? buf.substring(0, buf.length() - 1) : buf.toString(); } return node.toString(); } return null; } }
@JsonSetter("user") public void setUser(JsonNode jsonNode) { if (jsonNode.isObject()) { try { this.user = new ObjectMapper().treeToValue(jsonNode, User.class); } catch (JsonProcessingException e) { logger.error("Error deserializing json: ", e); } } else if (jsonNode.isTextual()) { this.userId = jsonNode.asText(); } }