List of usage examples for com.fasterxml.jackson.databind.node ArrayNode add
public ArrayNode add(JsonNode paramJsonNode)
From source file:net.hamnaberg.json.generator.CollectionGeneratorTest.java
private ObjectNode createTemplate() { ArrayNode arrayNode = nodeFactory.arrayNode(); ObjectNode property = nodeFactory.objectNode(); property.put("name", "one"); property.put("prompt", "One"); arrayNode.add(property); ObjectNode template = nodeFactory.objectNode(); template.set("data", arrayNode); return template; }
From source file:com.github.fge.jsonschema.core.report.ProcessingMessageTest.java
@Test public void submittedCollectionAppliesToStringToElements() { final List<Object> list = Arrays.asList(new Object(), new Object()); final ArrayNode node = FACTORY.arrayNode(); for (final Object o : list) node.add(o.toString()); final ProcessingMessage msg = new ProcessingMessage().put("foo", list); assertMessage(msg).hasField("foo", node); }
From source file:com.github.fge.jsonschema.processors.validation.ObjectSchemaDigester.java
@Override public JsonNode digest(final JsonNode schema) { final ObjectNode ret = FACTORY.objectNode(); ret.put("hasAdditional", schema.path("additionalProperties").isObject()); Set<String> set; ArrayNode node; node = FACTORY.arrayNode();/*from w w w. j av a2s.c o m*/ ret.put("properties", node); set = Sets.newHashSet(schema.path("properties").fieldNames()); for (final String field : Ordering.natural().sortedCopy(set)) node.add(field); node = FACTORY.arrayNode(); ret.put("patternProperties", node); set = Sets.newHashSet(schema.path("patternProperties").fieldNames()); for (final String field : Ordering.natural().sortedCopy(set)) node.add(field); return ret; }
From source file:org.gitana.platform.client.repository.RepositoryImpl.java
@Override public PermissionCheckResults checkBranchPermissions(List<PermissionCheck> list) { ArrayNode array = JsonUtil.createArray(); for (PermissionCheck check : list) { array.add(check.getObject()); }//from w w w .ja v a2 s. co m ObjectNode object = JsonUtil.createObject(); object.put("checks", array); Response response = getRemote().post("/repositories/" + getId() + "/permissions/check", object); return new PermissionCheckResults(response.getObjectNode()); }
From source file:org.walkmod.conf.providers.yml.AbstractYMLConfigurationAction.java
public void populateWriterReader(ObjectNode root, String path, String type, String[] includes, String[] excludes, Map<String, Object> params) { if (path != null && !"".equals(path)) { root.set("path", new TextNode(path)); }//from www. j ava2s. c o m if (type != null) { root.set("type", new TextNode(type)); } if (includes != null && includes.length > 0) { ArrayNode includesNode = new ArrayNode(provider.getObjectMapper().getNodeFactory()); for (int i = 0; i < includes.length; i++) { includesNode.add(new TextNode(includes[i])); } root.set("includes", includesNode); } if (excludes != null && excludes.length > 0) { ArrayNode excludesNode = new ArrayNode(provider.getObjectMapper().getNodeFactory()); for (int i = 0; i < excludes.length; i++) { excludesNode.add(new TextNode(excludes[i])); } root.set("excludes", excludesNode); } if (params != null && !params.isEmpty()) { populateParams(root, params); } }
From source file:com.mirth.connect.client.ui.components.rsta.FindReplaceProperties.java
JsonNode toJsonNode() { ObjectNode rootNode = JsonNodeFactory.instance.objectNode(); ArrayNode findHistoryNode = rootNode.putArray("findHistory"); for (String element : findHistory) { findHistoryNode.add(StringUtils.abbreviate(element, 40)); }//from w w w .j a v a 2s.c o m ArrayNode replaceHistoryNode = rootNode.putArray("replaceHistory"); for (String element : replaceHistory) { replaceHistoryNode.add(StringUtils.abbreviate(element, 40)); } ObjectNode optionsNode = rootNode.putObject("options"); for (Entry<String, Boolean> entry : optionsMap.entrySet()) { optionsNode.put(entry.getKey(), entry.getValue()); } return rootNode; }
From source file:io.amient.kafka.metrics.Dashboard.java
public ArrayNode newArray(String... values) { ArrayNode node = mapper.createArrayNode(); for (String v : values) node.add(v); return node;/*from w ww . j a v a 2 s . c o m*/ }
From source file:com.github.reinert.jjschema.v1.CustomSchemaWrapper.java
public void addRequired(String name) { if (!getNode().has(TAG_REQUIRED)) getNode().putArray(TAG_REQUIRED); ArrayNode requiredNode = (ArrayNode) getNode().get(TAG_REQUIRED); requiredNode.add(name); }
From source file:com.github.fge.jsonpatch.AddOperation.java
private JsonNode addToArray(final JsonPointer path, final JsonNode node) throws JsonPatchException { final JsonNode ret = node.deepCopy(); final ArrayNode target = (ArrayNode) path.parent().get(ret); final TokenResolver<JsonNode> token = Iterables.getLast(path); if (token.getToken().equals(LAST_ARRAY_ELEMENT)) { target.add(value); return ret; }/*w ww.ja v a 2 s .c om*/ final int size = target.size(); final int index; try { index = Integer.parseInt(token.toString()); } catch (NumberFormatException ignored) { throw new JsonPatchException(BUNDLE.getMessage("jsonPatch.notAnIndex")); } if (index < 0 || index > size) throw new JsonPatchException(BUNDLE.getMessage("jsonPatch.noSuchIndex")); target.insert(index, value); return ret; }
From source file:org.n52.io.geojson.GeoJSONEncoder.java
protected ArrayNode encodeCoordinates(CoordinateSequence coordinates) { ArrayNode list = jsonFactory.arrayNode(); for (int i = 0; i < coordinates.size(); ++i) { list.add(encodeCoordinate(coordinates.getCoordinate(i))); }/*www . j a v a 2 s. c o m*/ return list; }