Example usage for javax.json JsonArrayBuilder add

List of usage examples for javax.json JsonArrayBuilder add

Introduction

In this page you can find the example usage for javax.json JsonArrayBuilder add.

Prototype

JsonArrayBuilder add(JsonArrayBuilder builder);

Source Link

Document

Adds a JsonArray from an array builder to the array.

Usage

From source file:co.runrightfast.core.utils.JsonUtils.java

static JsonArray toJsonArray(final String[] stringList) {
    if (ArrayUtils.isEmpty(stringList)) {
        return EMPTY_ARRAY;
    }// www  .jav a2s.c o  m

    final JsonArrayBuilder builder = Json.createArrayBuilder();
    for (int i = 0; i < stringList.length; i++) {
        builder.add(stringList[i]);
    }
    return builder.build();
}

From source file:org.jboss.set.aphrodite.stream.services.json.StreamComponentJsonParser.java

private static JsonArrayBuilder encodeContacts(List<String> list) {
    final JsonArrayBuilder array = Json.createArrayBuilder();
    for (String s : list) {
        array.add(s);
    }/*from w  w w . java  2 s . c o m*/
    return array;
}

From source file:org.jboss.set.aphrodite.stream.services.json.StreamsJsonParser.java

private static JsonArrayBuilder encodeStreams(Collection<Stream> streams) {
    final JsonArrayBuilder array = Json.createArrayBuilder();
    for (Stream s : streams) {
        array.add(encodeStream(s));
    }/*www. j a va 2  s  .c  om*/
    return array;
}

From source file:co.runrightfast.vertx.core.protobuf.MessageConversions.java

static JsonArray toJsonArray(final Collection<RunRightFastVerticleDeployment> deployments) {
    if (deployments == null) {
        return JsonUtils.EMPTY_ARRAY;
    }//from  ww w. j a  v  a 2s.  c om

    final JsonArrayBuilder jsonArray = Json.createArrayBuilder();
    deployments.stream().forEach(deployment -> jsonArray.add(deployment.toJson()));
    return jsonArray.build();
}

From source file:org.jboss.set.aphrodite.stream.services.json.StreamsJsonParser.java

private static JsonArrayBuilder encodeStreamComponents(Collection<StreamComponent> components) {
    final JsonArrayBuilder array = Json.createArrayBuilder();
    for (StreamComponent c : components) {
        array.add(StreamComponentJsonParser.encodeStreamComponent(c));
    }/*from w  w w. j a va2  s.com*/
    return array;
}

From source file:edu.harvard.iq.dataverse.api.HarvestingServer.java

public static JsonArrayBuilder oaiSetsAsJsonArray(List<OAISet> oaiSets) {
    JsonArrayBuilder hdArr = Json.createArrayBuilder();

    for (OAISet set : oaiSets) {
        hdArr.add(oaiSetAsJson(set));
    }//from   w w  w.ja  v  a  2  s  . c  om
    return hdArr;
}

From source file:com.buffalokiwi.aerodrome.jet.Utils.java

public static <T extends Jsonable> JsonArray jsonableToArray(List<T> data) {
    final JsonArrayBuilder ab = Json.createArrayBuilder();

    if (data != null) {
        for (T t : data) {
            ab.add(t.toJSON());
        }//from  www.  j a  va  2 s. com
    }

    return ab.build();
}

From source file:org.apache.nifi.reporting.SiteToSiteProvenanceReportingTask.java

private static JsonArrayBuilder createJsonArray(JsonBuilderFactory factory, final Collection<String> values) {
    final JsonArrayBuilder builder = factory.createArrayBuilder();
    for (final String value : values) {
        if (value != null) {
            builder.add(value);
        }/*w  w w. ja  va  2s. c  o  m*/
    }
    return builder;
}

From source file:com.buffalokiwi.aerodrome.jet.Utils.java

/**
 * Turn some list of Jsonable into a json array 
 * @param <T>/*from www.  j  a va2 s  .  c  om*/
 * @param data list
 * @return json array 
 */
public static <T extends Object> JsonArray toJsonArray(List<T> data) {
    final JsonArrayBuilder out = Json.createArrayBuilder();

    for (final Object obj : data) {
        if (obj == null)
            out.addNull();
        else if (obj instanceof Jsonable)
            out.add(((Jsonable) obj).toJSON());
        else if (obj instanceof JsonValue)
            out.add((JsonValue) obj);
        else if (obj instanceof BigDecimal)
            out.add((BigDecimal) obj);
        else if (obj instanceof BigInteger)
            out.add((BigInteger) obj);
        else if (obj instanceof Integer)
            out.add((Integer) obj);
        else if (obj instanceof Long)
            out.add((Long) obj);
        else if (obj instanceof Double)
            out.add((Double) obj);
        else if (obj instanceof Boolean)
            out.add((Boolean) obj);
        else if (obj instanceof JsonObjectBuilder)
            out.add((JsonObjectBuilder) obj);
        else if (obj instanceof JsonArrayBuilder)
            out.add((JsonArrayBuilder) obj);
        else
            out.add(obj.toString());
    }

    return out.build();
}

From source file:org.dcm4che3.tool.qc.QC.java

private static JsonArrayBuilder toArrayBuilder(ArrayList<String> moveUIDs) {
    JsonArrayBuilder arr = Json.createArrayBuilder();
    for (String str : moveUIDs)
        arr.add(str);
    return arr;/*  w  ww.j a va2s.c  om*/
}