Example usage for com.fasterxml.jackson.databind.node ArrayNode add

List of usage examples for com.fasterxml.jackson.databind.node ArrayNode add

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind.node ArrayNode add.

Prototype

public ArrayNode add(JsonNode paramJsonNode) 

Source Link

Usage

From source file:com.rusticisoftware.tincan.About.java

@Override
public ObjectNode toJSONNode(TCAPIVersion v) {
    ObjectNode result = new ObjectNode(Mapper.getInstance().getNodeFactory());
    if (!version.isEmpty()) {
        ArrayNode versions = Mapper.getInstance().createArrayNode();
        for (TCAPIVersion tcapiVersion : this.getVersion()) {
            versions.add(tcapiVersion.toString());
        }/*from w  ww. j  av  a 2s.c o  m*/
        result.put("version", versions);
    }

    if (extensions != null) {
        result.put("extensions", extensions.toJSONNode());
    }

    return result;
}

From source file:org.gitana.platform.client.job.JobLogEntry.java

public void setStackTrace(StackTraceElement[] elements) {
    ArrayNode array = JsonUtil.createArray();

    for (StackTraceElement element : elements) {
        array.add(element.toString());
    }/*from  w w w.jav a 2s  .c om*/

    set(FIELD_STACKTRACE, array);
}

From source file:org.opendaylight.sfc.sbrest.provider.task.SbRestSfTaskTest.java

private ObjectNode buildServiceFunctionTopNode() {
    ObjectNode topNode = mapper.createObjectNode();
    ArrayNode arrayNode = mapper.createArrayNode();
    ObjectNode sfNode = mapper.createObjectNode();

    arrayNode.add(sfNode);
    topNode.put(SfExporterFactory._SERVICE_FUNCTION, arrayNode);
    return topNode;
}

From source file:org.apache.drill.optiq.DrillUnionRel.java

@Override
public int implement(DrillImplementor implementor) {
    List<Integer> inputIds = new ArrayList<>();
    for (Ord<RelNode> input : Ord.zip(inputs)) {
        inputIds.add(implementor.visitChild(this, input.i, input.e));
    }/*w  w  w . j  av a  2s.c o m*/
    /*
        E.g. {
          op: "union",
          distinct: true,
         inputs: [2, 4]
       }
    */
    final ObjectNode union = implementor.mapper.createObjectNode();
    union.put("op", "union");
    union.put("distinct", !all);
    final ArrayNode inputs = implementor.mapper.createArrayNode();
    union.put("inputs", inputs);
    for (Integer inputId : inputIds) {
        inputs.add(inputId);
    }
    return implementor.add(union);
}

From source file:com.clicktravel.infrastructure.persistence.aws.cloudsearch.client.JsonDocumentUpdateMarshaller.java

private String marshallDocumentUpdates(final Collection<DocumentUpdate> documentUpdates) {
    try {/*  ww  w .jav a2 s.com*/
        final ArrayNode documentUpdateCollectionNode = mapper.createArrayNode();
        for (final DocumentUpdate documentUpdate : documentUpdates) {
            documentUpdateCollectionNode.add(createJsonNode(documentUpdate));
        }
        return mapper.writeValueAsString(documentUpdateCollectionNode);
    } catch (final Exception e) {
        throw new IllegalStateException(e);
    }
}

From source file:org.opendaylight.sfc.sbrest.provider.task.SbRestRspTaskTest.java

private ObjectNode buildRenderedServicePathObjectNode() {
    ObjectNode topNode = mapper.createObjectNode();

    ObjectNode rspNode = mapper.createObjectNode();
    rspNode.put(RspExporterFactory._NAME, RSP_NAME.getValue());

    ObjectNode hopNode = mapper.createObjectNode();
    hopNode.put(RspExporterFactory._SERVICE_FUNCTION_FORWARDER, SFF_NAME.getValue());

    ArrayNode hopArrayNode = mapper.createArrayNode();
    hopArrayNode.add(hopNode);

    rspNode.put(RspExporterFactory._RENDERED_SERVICE_PATH_HOP, hopArrayNode);

    ArrayNode rspArrayNode = mapper.createArrayNode();
    rspArrayNode.add(rspNode);//from   ww  w . j a v  a 2  s .c o  m

    topNode.put(RspExporterFactory._RENDERED_SERVICE_PATH, rspArrayNode);
    return topNode;
}

From source file:io.sqp.transbase.TBTypeRepository.java

private String createDateTimeSchema(DateRangeSpecifier highField, DateRangeSpecifier lowField) {
    List<DateRangeSpecifier> fields = DateRangeSpecifier.range(highField, lowField);
    ObjectNode schema = createDateTimeSchemaSkeleton(highField, lowField);
    ArrayNode items = _objectMapper.createArrayNode();
    fields.forEach(f -> items.add(createTypeFromSpecifier(f)));
    schema.set("items", items);
    schema.put("minItems", fields.size());
    schema.put("additionalItems", false);
    return schema.toString();
}

From source file:eu.europa.ec.fisheries.uvms.rest.FeatureToGeoJsonJacksonMapper.java

@SuppressWarnings("unchecked")
private ObjectNode buildProperties(SimpleFeature simpleFeature) {
    ObjectNode obj = mapper.createObjectNode();
    Collection<Property> properties = simpleFeature.getProperties();
    for (Property property : properties) {
        final Object value = property.getValue();

        if (!property.getName().getLocalPart().equals(GEOMETRY)) {
            if (ArrayList.class.equals(property.getType().getBinding())) {
                ArrayNode arrayNode = mapper.createArrayNode();
                for (Object o : (ArrayList) value) {
                    arrayNode.add(o.toString());
                }/*w  w w.  j  a  va2s .  co  m*/
                obj.putArray(property.getName().toString()).addAll(arrayNode);
            } else if (Double.class.equals(property.getType().getBinding())) {
                obj.put(property.getName().toString(), value == null ? 0D : (double) value);
            } else {
                obj.put(property.getName().toString(), value == null ? StringUtils.EMPTY : value.toString());
            }
        }
    }
    return obj;
}

From source file:net.bcsw.sdnwlan.web.SDNWLANAccessPointCodec.java

@Override
public ObjectNode encode(AccessPointConfig entry, CodecContext context) {
    checkNotNull(entry, "Access Point Entry cannot be null");

    final ObjectNode result = context.mapper().createObjectNode().put(NAME, entry.getName());
    result.put(MAC_ADDRESS, entry.getMacAddress().toString());

    // TODO: Need to redo this for new DefaultGatway class
    final ArrayNode jsonCIDRs = result.putArray(DEFAULT_GATEWAYS);
    entry.getDefaultGatewayList().forEach(ip -> jsonCIDRs.add(ip.toString()));

    final ArrayNode jsonConns = result.putArray(CONNECTIONS);
    entry.getConnections().forEach(cp -> jsonConns.add(cp.toString()));

    // TODO: Need to redo this for new ingress VLAN descriptor and gateway classes

    result.put(LONGITUDE, entry.getLongitude());
    result.put(LATITUDE, entry.getLatitude());
    result.put(ALTITUDE, entry.getAltitude());

    final ArrayNode jsonOthers = result.putArray(OTHER_VIDS);
    entry.getOtherVids().forEach((k, v) -> {
        result.put(OTHER_VIDS_GATEWAY, k.toString());
        final ArrayNode otherVlans = result.putArray(OTHER_VIDS_VLANS);
        v.forEach(vid -> otherVlans.add(vid.toShort()));
    });/*from   w w  w .j  ava2  s.co m*/
    return result;
}

From source file:org.createnet.raptor.models.data.ResultSet.java

/**
 * Return the JsonNode representation of the ResultSet
 * @return JsonNode representation of the ResultSet
 *///from   w  w w . ja v a2 s . c om
public ArrayNode toJsonNode() {
    ObjectMapper mapper = ServiceObject.getMapper();
    ArrayNode list = mapper.createArrayNode();
    this.forEach((record) -> {
        list.add(record.toJsonNode());
    });
    return list;
}