List of usage examples for com.fasterxml.jackson.databind.node ObjectNode get
public JsonNode get(String paramString)
From source file:com.ethlo.geodata.restdocs.AbstractJacksonFieldSnippet.java
protected ObjectNode getSchema(Operation operation, final Class<?> pojo, boolean isResponse) { try {/*w w w.j a v a 2 s .c om*/ final ObjectNode schema = (ObjectNode) generator.generateSchema(pojo, isResponse); final Collection<FieldDescriptor> fieldDescriptors = createFieldDescriptors(operation, pojo); // Add field descriptions on top of JSON schema fieldDescriptors.forEach(desc -> { final String[] pathArr = org.apache.commons.lang3.StringUtils.split(desc.getPath(), '.'); final Iterator<String> path = Arrays.asList(pathArr).iterator(); final ObjectNode definitionsNode = schema.get("definitions") != null ? (ObjectNode) schema.get("definitions") : schema.objectNode(); handleSchema(pojo, schema, definitionsNode, desc, path); }); allSchemas.put(pojo, schema); ((ObjectNode) schema).remove("definitions"); return schema; } catch (RuntimeException exc) { exc.printStackTrace(); throw exc; } }
From source file:com.redhat.lightblue.metadata.parser.JSONMetadataParserTest.java
License:asdf
@Test public void putValueFloat() { ObjectNode parent = new ObjectNode(factory); String name = "foo"; Float value = new Float("123.222"); parser.putValue(parent, name, value); JsonNode x = parent.get(name);// www .ja va 2s.com Assert.assertNotNull(x); Assert.assertEquals(value.floatValue(), x.floatValue(), 0.001); }
From source file:com.redhat.lightblue.metadata.parser.JSONMetadataParserTest.java
License:asdf
@Test public void putValueDouble() { ObjectNode parent = new ObjectNode(factory); String name = "foo"; Double value = new Double("12928.222"); parser.putValue(parent, name, value); JsonNode x = parent.get(name);/*from w w w . ja v a 2s . c o m*/ Assert.assertNotNull(x); Assert.assertEquals(value.doubleValue(), x.doubleValue(), 0.001); }
From source file:com.redhat.lightblue.metadata.parser.JSONMetadataParserTest.java
License:asdf
@Test public void putObject() { ObjectNode parent = new ObjectNode(factory); String name = "foo"; Object value = new ObjectNode(factory); parser.putObject(parent, name, value); JsonNode x = parent.get(name);/* w w w .ja va2s. co m*/ Assert.assertNotNull(x); Assert.assertTrue("expected instanceof ObjectNode", x instanceof ObjectNode); Assert.assertEquals(value, x); }
From source file:com.marklogic.samplestack.database.DatabaseQnADocumentSearchIT.java
@Test public void testActivitySearch() { JsonNode query;//from ww w. j a v a 2 s . c om ObjectNode results = null; try { query = mapper.readValue( "{\"query\":" + "{\"range-constraint-query\":" + "{\"constraint-name\":\"lastActivity\", " + "\"value\":\"2015-08-09T18:16:56.809Z\", " + "\"range-operator\":\"GT\"}}}", JsonNode.class); results = operations.qnaSearch(ClientRole.SAMPLESTACK_CONTRIBUTOR, query, 1, QueryView.ALL); logger.debug("Query Results:" + mapper.writeValueAsString(results)); logger.debug("Query Text:" + mapper.writeValueAsString(results.get("report"))); } catch (IOException e) { throw new SamplestackIOException(e); } assertEquals("JSON has 0 result", 0, results.get("total").asInt()); try { query = mapper.readValue( "{\"query\":" + "{\"range-constraint-query\":" + "{\"constraint-name\":\"lastActivity\", " + "\"value\":\"2015-08-09T18:16:56.809Z\", " + "\"range-operator\":\"LT\"}}}", JsonNode.class); results = operations.qnaSearch(ClientRole.SAMPLESTACK_CONTRIBUTOR, query, 1, QueryView.ALL); logger.debug("Query Results:" + mapper.writeValueAsString(results)); logger.debug("Query Text:" + mapper.writeValueAsString(results.get("report"))); } catch (IOException e) { throw new SamplestackIOException(e); } assertTrue("JSON has >0 result", results.get("total").asInt() > 0); }
From source file:com.redhat.lightblue.metadata.parser.JSONMetadataParserTest.java
License:asdf
@Test public void putValueBigDecimal() { ObjectNode parent = new ObjectNode(factory); String name = "foo"; BigDecimal value = new BigDecimal("213.55"); parser.putValue(parent, name, value); JsonNode x = parent.get(name);//w w w . j a v a 2 s . co m Assert.assertNotNull(x); Assert.assertEquals(value, x.decimalValue()); }
From source file:com.redhat.lightblue.metadata.parser.JSONMetadataParserTest.java
License:asdf
@Test public void putValueBigInteger() { ObjectNode parent = new ObjectNode(factory); String name = "foo"; BigInteger value = new BigInteger("123444"); parser.putValue(parent, name, value); JsonNode x = parent.get(name);/*from w w w . j a v a 2 s . c o m*/ Assert.assertNotNull(x); Assert.assertEquals(value, x.bigIntegerValue()); }
From source file:com.almende.eve.agent.google.GoogleCalendarAgent.java
/** * Convert the event from a Eve event to a Google event * /*from w w w . ja v a2s .co m*/ * @param event */ private void toGoogleEvent(final ObjectNode event) { if (event.has("agent") && event.get("agent").isTextual()) { // move agent url from event.agent to extendedProperties final String agent = event.get("agent").asText(); event.with("extendedProperties").with("shared").put("agent", agent); // TODO: change location into a string } }