List of usage examples for com.fasterxml.jackson.databind JsonNode get
public JsonNode get(String paramString)
From source file:io.syndesis.dao.DeploymentDescriptorTest.java
private static void assertActionDataShapes(final CamelConnectorCatalog connectorCatalog, final JsonNode action, final String actionName, final String... coordinates) { final String connectorJSon = connectorCatalog.connectorJSon(coordinates[0], coordinates[1], coordinates[2]); JsonNode connectorJson;//from www.j a va 2 s .c o m try { connectorJson = MAPPER.readTree(connectorJSon); } catch (final IOException e) { fail("Unable to parse connector JSON descriptor", e); return; // never happens } final String connectorInputDataType = connectorJson.get("inputDataType").asText(); final String connectorOutputDataType = connectorJson.get("outputDataType").asText(); final JsonNode actionDefinition = action.get("definition"); final JsonNode inputDataShape = actionDefinition.get("inputDataShape"); if ("json".equals(connectorInputDataType)) { assertThat(inputDataShape.get("kind").asText()) .as("Connector defines input data shape for action %s as JSON, deployment descriptor does not", actionName) .isEqualTo("json-schema"); assertThat(inputDataShape.get("type")) .as("shapes of kind `json-schema` should not define type, input data shape of %s does", actionName) .isNull(); } final JsonNode outputDataShape = actionDefinition.get("outputDataShape"); if ("json".equals(connectorOutputDataType)) { assertThat(outputDataShape.get("kind").asText()) .as("Connector defines output data shape for action %s as JSON, deployment descriptor does not", actionName) .isEqualTo("json-schema"); assertThat(outputDataShape.get("type")) .as("shapes of kind `json-schema` should not define type, output data shape of %s does", actionName) .isNull(); } if (connectorInputDataType.startsWith("java:")) { assertThat(inputDataShape.get("kind").asText()) .as("Connector defines input data shape for action %s as java, deployment descriptor does not", actionName) .isEqualTo("java"); assertThat(inputDataShape.get("type").asText()) .as("Connector input data shape for action %s differs in class name from deployment", actionName) .isEqualTo(connectorInputDataType.substring(5)); } if (connectorOutputDataType.startsWith("java:")) { assertThat(outputDataShape.get("kind").asText()) .as("Connector defines output data shape for action %s as java, deployment descriptor does not", actionName) .isEqualTo("java"); assertThat(outputDataShape.get("type").asText()) .as("Connector output data shape for action %s differs in class name from deployment", actionName) .isEqualTo(connectorOutputDataType.substring(5)); } if ("none".equals(connectorInputDataType)) { assertThat(inputDataShape.get("kind").asText()) .as("Connector defines input data shape for action %s as none, deployment descriptor does not", actionName) .isEqualTo("none"); assertThat(inputDataShape.get("type")) .as("shapes of kind `none` should not define type, input data shape of %s does", actionName) .isNull(); } if ("none".equals(connectorOutputDataType)) { assertThat(outputDataShape.get("kind").asText()) .as("Connector defines output data shape for action %s as none, deployment descriptor does not", actionName) .isEqualTo("none"); assertThat(outputDataShape.get("type")) .as("shapes of kind `none` should not define type, output data shape of %s does", actionName) .isNull(); } }
From source file:org.apache.solr.kelvin.scorer.TypedTestScorer.java
@Override public void configure(JsonNode config) throws Exception { type = config.get("scorerClass").asText(); typeClass = Class.forName(type); }
From source file:br.com.hyperclass.snackbar.restapi.deserializer.PaySaleDeserialize.java
@Override public PaySaleWrapper deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); return new PaySaleWrapper(node.get("money").asDouble(), node.get("typeSale").asText()); }
From source file:br.com.hyperclass.snackbar.restapi.deserializer.ProductDeserialize.java
@Override public ProductWrapper deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); return new ProductWrapper(node.get("name").asText(), node.get("price").asDouble()); }
From source file:org.eel.kitchen.jsonschema.syntax.DivisibleBySyntaxChecker.java
@Override void checkValue(final Message.Builder msg, final List<Message> messages, final JsonNode schema) { final JsonNode node = schema.get(keyword); if (node.decimalValue().compareTo(ZERO) > 0) return;// w w w . j a v a2s. c o m msg.setMessage("divisibleBy is not strictly greater than 0").addInfo("value", node); messages.add(msg.build()); }
From source file:org.jboss.pnc.buildagent.api.TaskStatusUpdateEventDeserializer.java
@Override public TaskStatusUpdateEvent deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonNode node = jp.getCodec().readTree(jp); String taskId = node.get("taskId").asText(); String oldStatus = node.get("oldStatus").asText(); String newStatus = node.get("newStatus").asText(); String context = node.get("context").asText(); return new TaskStatusUpdateEvent(taskId, Status.valueOf(oldStatus), Status.valueOf(newStatus), context); }
From source file:org.lendingclub.mercator.aws.SubnetScanner.java
@Override public Optional<String> computeArn(JsonNode n) { String region = n.get(AWSScanner.AWS_REGION_ATTRIBUTE).asText(); return Optional.of(String.format("arn:aws:ec2:%s:%s:subnet/%s", region, n.get(AccountScanner.ACCOUNT_ATTRIBUTE).asText(), n.get("aws_subnetId").asText())); }
From source file:io.sqp.schemamatcher.typematchers.TypeMatcher.java
@Override final public boolean isCompatibleTo(JsonNode other) { JsonNode typeField = other.get("type"); if (typeField == null) { throw new InvalidMatchingSchemaException("Type field is not set. Expected type '" + _type + "'."); }/*from w ww . ja v a 2 s. c o m*/ return _type.matches(typeField.asText()) && isTypeCompatibleTo(other); }
From source file:managers.nodes.PartManager.java
public Promise<List<Part>> all() { Promise<List<JsonNode>> json = all(this.label); return json.map(new Function<List<JsonNode>, List<Part>>() { public List<Part> apply(List<JsonNode> json) { List<Part> parts = new ArrayList<Part>(); for (JsonNode node : json) { String content = node.get("content").asText(); parts.add(new Part(content)); }//from ww w. j a v a 2 s .c om return parts; } }); }
From source file:br.com.hyperclass.snackbar.restapi.deserializer.SalesDateDeserialize.java
@Override public SalesDateWrapper deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException, JsonProcessingException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); return new SalesDateWrapper(node.get("dateInitial").asLong(), node.get("dateFinal").asLong()); }