List of usage examples for com.fasterxml.jackson.databind.node ArrayNode add
public ArrayNode add(JsonNode paramJsonNode)
From source file:scott.barleyrs.rest.AdminService.java
private ArrayNode enumValuesAsJsonArray(ObjectMapper mapper, EnumSpec enumSpec) { ArrayNode enumValues = mapper.createArrayNode(); for (EnumValueSpec ev : enumSpec.getEnumValues()) { enumValues.add(ev.getName()); }/*from w ww . j ava 2 s .c om*/ return enumValues; }
From source file:com.almende.eve.agent.AgentConfig.java
/** * Sets the transport./*from ww w. j av a 2s .c o m*/ * * @deprecated Please use setTransports(transport[]) or * addTransport(transport) instead * @param transport * the new transport */ @Deprecated public void setTransport(final JsonNode transport) { if (transport == null) { setTransports(JOM.createArrayNode()); } else if (transport.isArray()) { setTransports((ArrayNode) transport); } else { ArrayNode other = JOM.createArrayNode(); other.add(transport); setTransports(other); } }
From source file:org.dswarm.graph.maintain.test.MaintainResourceDeprecateTest.java
public String deprecateRecords(final String dataModelURI, final Collection<String> recordURIs) throws JsonProcessingException { final ObjectNode requestJSON = objectMapper.createObjectNode(); requestJSON.put(DMPStatics.DATA_MODEL_URI_IDENTIFIER, dataModelURI); final ArrayNode recordsArray = objectMapper.createArrayNode(); for (final String recordURI : recordURIs) { recordsArray.add(recordURI); }/*from w w w.java 2s . co m*/ requestJSON.set(DMPStatics.RECORDS_IDENTIFIER, recordsArray); final String request = objectMapper.writeValueAsString(requestJSON); final ClientResponse response = service().path("/maintain/deprecate/records") .type(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON) .post(ClientResponse.class, request); Assert.assertEquals("expected 200", 200, response.getStatus()); final String body = response.getEntity(String.class); Assert.assertNotNull("response body shouldn't be null", body); return body; }
From source file:org.lendingclub.mercator.aws.Route53Scanner.java
ObjectNode toJson(ResourceRecordSet rs) { ObjectNode n = mapper.createObjectNode(); n.put("aws_ttl", rs.getTTL()); n.put("aws_type", rs.getType()); n.put("aws_name", rs.getName()); n.put("id", rs.getType() + "_" + rs.getName()); ArrayNode an = mapper.createArrayNode(); n.set("aws_resourceRecords", an); for (ResourceRecord rr : rs.getResourceRecords()) { an.add(rr.getValue()); }//from w ww.j a v a2s. c om return n; }
From source file:com.activiti.service.activiti.ProcessInstanceService.java
public void createVariable(ServerConfig serverConfig, String processInstanceId, ObjectNode objectNode) { URIBuilder builder = clientUtil/*from w ww . j a v a 2 s . c o m*/ .createUriBuilder(MessageFormat.format(RUNTIME_PROCESS_INSTANCE_VARIABLES, processInstanceId)); HttpPost post = clientUtil.createPost(builder, serverConfig); ArrayNode variablesNode = objectMapper.createArrayNode(); variablesNode.add(objectNode); post.setEntity(clientUtil.createStringEntity(variablesNode.toString())); clientUtil.executeRequest(post, serverConfig, 201); }
From source file:kr.ac.postech.lispconfig.rest.AppWebResource.java
@GET @Path("/devices") public Response getDevices() { DeviceService deviceService = get(DeviceService.class); ObjectNode node = mapper().createObjectNode(); ArrayNode arrayNode = node.putArray("devices"); deviceService.getDevices()/*from www.j ava 2s . c om*/ .forEach(d -> arrayNode.add(mapper().createObjectNode().put("deviceId", d.id().toString()))); return ok(node).build(); }
From source file:com.redhat.lightblue.ResponseTest.java
@Test public void testWithEntityDataArray() { node = JsonNodeFactory.withExactBigDecimals(true).arrayNode(); ArrayNode anode = (ArrayNode) node; anode.add(anode.objectNode()); anode.add(anode.objectNode());//from www . j av a2 s .c om builder.withEntityData(node); assertEquals(2, builder.buildResponse().getEntityData().size()); assertTrue(node.equals(builder.buildResponse().getEntityData())); }
From source file:io.sidecar.event.EventJsonValidationTest.java
@Test(description = "Assert that an event can have duplicate tags") public void tagsCanBeDuplicated() throws Exception { Set<String> originalTagSet = tagsJsonArrayToSet(); ArrayNode tagsNode = (ArrayNode) eventAsObjectNode.path("tags"); tagsNode.add(tagsNode.get(0)); Event e = mapper.readValue(eventAsObjectNode.traverse(), Event.class); assertEquals(e.getTags(), originalTagSet); }
From source file:com.github.fge.jsonschema.processors.validation.ValidationStack.java
private ProcessingMessage validationLoopMessage(final FullData input) { final ArrayNode node = JacksonUtils.nodeFactory().arrayNode(); for (final SchemaURI uri : schemaURIs) node.add(uri.toString()); return input.newMessage().put("domain", "validation").setMessage(errmsg) .putArgument("alreadyVisited", new SchemaURI(input.getSchema())) .putArgument("instancePointer", pointer.toString()).put("validationPath", node); }
From source file:io.macgyver.neorx.rest.NeoRxClientIntegrationTest.java
@Test public void testArray() throws JsonProcessingException, IOException { ObjectMapper m = new ObjectMapper(); ArrayNode an = m.createArrayNode(); an.add("foo"); an.add("bar"); ArrayNode an2 = m.createArrayNode(); an2.add(1);//from ww w.j a va 2s . com an2.add(2); JsonNode n = getClient().execCypher("create (a:JUnit) set a.array1={array1},a.array2={array2} return a", "array1", an, "array2", an2).toBlocking().first(); Assertions.assertThat(n.path("array1").get(0).asText()).isEqualTo("foo"); Assertions.assertThat(n.path("array1").get(1).asText()).isEqualTo("bar"); Assertions.assertThat(n.path("array2").get(0).asInt()).isEqualTo(1); Assertions.assertThat(n.path("array2").get(1).asInt()).isEqualTo(2); }