Package com.fasterxml.jackson.databind.node

Examples of com.fasterxml.jackson.databind.node.ArrayNode


    }

    @Override
    public Iterable<?> toIterable(Object obj) {
        if (isArray(obj)) {
            ArrayNode arr = toJsonArray(obj);
            List<Object> values = new ArrayList<Object>(arr.size());
            for (Object o : arr) {
                values.add(unwrap(o));
            }
            return values;
        } else {
View Full Code Here


  public JsonNode createJsonNode(Boolean parameter) {
    return getConfiguredObjectMapper().getNodeFactory().booleanNode(parameter);
  }

  public JsonNode createJsonNode(List<Object> parameter) {
    ArrayNode node = getConfiguredObjectMapper().getNodeFactory().arrayNode();
    for(Object entry : parameter) {
      node.add(createJsonNode(entry));
    }
    return node;
  }
View Full Code Here

  }

  public SpinJsonNode append(Object property) {
    ensureNotNull("property", property);
    if(jsonNode.isArray()) {
      ArrayNode node = (ArrayNode) jsonNode;

      node.add(dataFormat.createJsonNode(property));

      return this;
    } else {
      throw LOG.unableToModifyNode(jsonNode.getNodeType().name());
    }
View Full Code Here

  public SpinJsonNode insertAt(int index, Object property) {
    ensureNotNull("property", property);

    if(jsonNode.isArray()) {
      index = getCorrectIndex(index);
      ArrayNode node = (ArrayNode) jsonNode;

      node.insert(index, dataFormat.createJsonNode(property));

      return this;
    } else {
      throw LOG.unableToModifyNode(jsonNode.getNodeType().name());
    }
View Full Code Here

    return removeAt(lastIndexOf(property));
  }

  public SpinJsonNode removeAt(int index) {
    if(this.isArray()) {
      ArrayNode node = (ArrayNode) jsonNode;

      node.remove(getCorrectIndex(index));

      return this;
    } else {
      throw LOG.unableToModifyNode(jsonNode.getNodeType().name());
    }
View Full Code Here

        return false;
    }

    @JsonProperty("events")
    public ArrayNode getEventsName() {
        ArrayNode result = new ArrayNode(JsonNodeFactory.instance);

        for (Event event : events) {
            ObjectNode eventJson = Json.newObject();
            eventJson.put("id", event.getId());
            eventJson.put("shortName", event.getShortName());
            result.add(eventJson);
        }

        return result;
    }
View Full Code Here

        return ok();
    }

    public static Result getTypes() {
        ArrayNode result = new ArrayNode(JsonNodeFactory.instance);

        for(LinkType linkType : LinkType.values()){
            ObjectNode typeJson = Json.newObject();
            typeJson.put("id", linkType.name());
            typeJson.put("label", linkType.getLabel());
            typeJson.put("icon", linkType.getIcon());
            typeJson.put("url", linkType.getUrl());
            result.add(typeJson);
        }



View Full Code Here

        String newUrl = null;
        LinkType newLinkType = LinkType.OTHER;
        JsonNode userJson = request().body().asJson();

        // Parcour des links du user;
        ArrayNode liens = (ArrayNode) userJson.get("links");
        for (JsonNode lien : liens) {
            if (lien.get("id") != null) {
                Form<Link> oneLienForm = form(Link.class).bind(lien);
                if (oneLienForm.hasErrors()) {
                    Map<String, Map<String, List<String>>> errors = new HashMap<String, Map<String, List<String>>>();
View Full Code Here

                String key = iterator.next();
                map.put(key, fromJsonNode(objectNode.get(key)));
            }
            return map;
        } else if (node.isArray()) {
            final ArrayNode arrayNode = (ArrayNode) node;
            final ArrayList<Object> array = new ArrayList<>();
            for (int i = 0; i < arrayNode.size(); i++) {
                array.add(fromJsonNode(arrayNode.get(i)));
            }
            return array;
        } else if (node.isFloatingPointNumber())
            return node.asDouble();
        else if (node.isIntegralNumber())
View Full Code Here

    final ObjectNode join = implementor.mapper.createObjectNode();
    join.put("op", "join");
    join.put("left", leftId);
    join.put("right", rightId);
    join.put("type", toDrill(joinType));
    final ArrayNode conditions = implementor.mapper.createArrayNode();
    join.put("conditions", conditions);
    for (Pair<Integer, Integer> pair : Pair.zip(leftKeys, rightKeys)) {
      final ObjectNode condition = implementor.mapper.createObjectNode();
      condition.put("relationship", "==");
      condition.put("left", leftFields.get(pair.left));
      condition.put("right", rightFields.get(pair.right));
      conditions.add(condition);
    }
    return implementor.add(join);
  }
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.databind.node.ArrayNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.