List of usage examples for com.fasterxml.jackson.databind.node ObjectNode put
public ObjectNode put(String paramString1, String paramString2)
From source file:com.github.fge.jsonschema.core.keyword.syntax.checkers.BasicSyntaxCheckerTest.java
@Test(dataProvider = "validTypes") public void syntaxCheckingSucceedsOnValidTypes(final JsonNode node) throws ProcessingException { final AbstractSyntaxChecker checker = spy(new DummyChecker()); final ProcessingReport report = mock(ProcessingReport.class); final ObjectNode schema = FACTORY.objectNode(); schema.put(KEYWORD, node); final SchemaTree tree = new CanonicalSchemaTree(SchemaKey.anonymousKey(), schema); checker.checkSyntax(null, BUNDLE, report, tree); verify(checker).checkValue(null, BUNDLE, report, tree); verify(report, never()).error(anyMessage()); }
From source file:org.envirocar.server.rest.encoding.json.SensorJSONEncoder.java
@Override public ObjectNode encodeJSON(Sensor t, AccessRights rights, MediaType mediaType) { ObjectNode sensor = getJsonFactory().objectNode(); if (t.hasType()) { sensor.put(JSONConstants.TYPE_KEY, t.getType()); }//from ww w .j a v a 2 s.co m Map<String, Object> properties = Maps.newHashMap(); if (t.hasProperties()) { properties.putAll(t.getProperties()); } properties.put(JSONConstants.IDENTIFIER_KEY, t.getIdentifier()); if (mediaType.equals(MediaTypes.SENSOR_TYPE)) { if (t.hasCreationTime()) { properties.put(JSONConstants.CREATED_KEY, getDateTimeFormat().print(t.getCreationTime())); } if (t.hasModificationTime()) { properties.put(JSONConstants.MODIFIED_KEY, getDateTimeFormat().print(t.getModificationTime())); } } sensor.putPOJO(JSONConstants.PROPERTIES_KEY, properties); return sensor; }
From source file:co.rsk.core.NetworkStateExporter.java
private ObjectNode createContractNode(ContractDetails contractDetails, ObjectNode accountNode) { ObjectNode contractNode = accountNode.objectNode(); contractNode.put("code", Hex.toHexString(contractDetails.getCode())); ObjectNode dataNode = contractNode.objectNode(); for (DataWord key : contractDetails.getStorageKeys()) { byte[] value = contractDetails.getBytes(key); dataNode.put(Hex.toHexString(key.getData()), Hex.toHexString(value)); }// w w w . j ava 2s .c o m contractNode.set("data", dataNode); return contractNode; }
From source file:com.googlecode.jsonschema2pojo.SchemaMapper.java
private ObjectNode readSchema(URL schemaUrl) { switch (ruleFactory.getGenerationConfig().getSourceType()) { case JSONSCHEMA: ObjectNode schemaNode = NODE_FACTORY.objectNode(); schemaNode.put("$ref", schemaUrl.toString()); return schemaNode; case JSON:/*from w w w . j ava 2 s . c o m*/ return schemaGenerator.schemaFromExample(schemaUrl); default: throw new IllegalArgumentException( "Unrecognised source type: " + ruleFactory.getGenerationConfig().getSourceType()); } }
From source file:com.rusticisoftware.tincan.AgentAccount.java
@Override public ObjectNode toJSONNode(TCAPIVersion version) { ObjectNode node = Mapper.getInstance().createObjectNode(); if (this.homePage != null) { node.put("homePage", this.getHomePage()); }/* www . ja v a2 s . co m*/ if (this.name != null) { node.put("name", this.getName()); } return node; }
From source file:net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportHealthCheckerTest.java
/** * Test method for {@link net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportHealthChecker#checkHealth(net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportActivity)}. * @throws Exception/*from w ww .ja v a 2 s .c o m*/ */ @Test public void testCheckHealth() throws Exception { assertEquals(Status.SEVERE, healthChecker.visit(activity, ancestors).getStatus()); ObjectNode configuration = JsonNodeFactory.instance.objectNode(); configuration.put("columnRange", configuration.objectNode().put("start", 0).put("end", 1)); configuration.put("rowRange", configuration.objectNode().put("start", 0).put("end", -1)); configuration.put("emptyCellValue", ""); configuration.put("allRows", true); configuration.put("excludeFirstRow", false); configuration.put("ignoreBlankRows", false); configuration.put("emptyCellPolicy", "EMPTY_STRING"); configuration.put("outputFormat", "PORT_PER_COLUMN"); configuration.put("csvDelimiter", ","); activity.configure(configuration); assertEquals(Status.OK, healthChecker.visit(activity, ancestors).getStatus()); }
From source file:org.fusesource.restygwt.examples.server.GreetingServlet.java
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { System.out.println("Creating custom greeting."); try {//from w w w . j av a 2 s .c om ObjectMapper mapper = new ObjectMapper(); ObjectNode nameObject = mapper.readValue(req.getInputStream(), ObjectNode.class); String name = nameObject.get("name").asText(); String greeting = "Hello " + name; ObjectNode resultObject = new ObjectNode(JsonNodeFactory.instance); resultObject.put("greeting", greeting); mapper.writeValue(resp.getOutputStream(), resultObject); } catch (Throwable e) { e.printStackTrace(); } finally { System.out.flush(); System.err.flush(); } }
From source file:net.hamnaberg.json.Link.java
public Link withHref(URI href) { ObjectNode node = copyDelegate(); node.put("href", href.toString()); return copy(node); }
From source file:net.hamnaberg.json.Link.java
public Link withRel(String rel) { ObjectNode node = copyDelegate(); node.put("rel", rel); return copy(node); }
From source file:net.hamnaberg.json.Link.java
public Link withPrompt(String prompt) { ObjectNode node = copyDelegate(); node.put("prompt", prompt); return copy(node); }