/** * Creates a new empty JsonArray. This is equivalent to creating a new JsonArray using the * constructor. * * @return a new empty JSON array */ public static JsonArray array() { return new JsonArray(); }
@Override public JsonArray startArray() { return new JsonArray(); }
/** * Returns an unmodifiable wrapper for the specified JsonArray. This method allows to provide * read-only access to a JsonArray. * <p> * The returned JsonArray is backed by the given array and reflects subsequent changes. Attempts * to modify the returned JsonArray result in an <code>UnsupportedOperationException</code>. * </p> * * @param array * the JsonArray for which an unmodifiable JsonArray is to be returned * @return an unmodifiable view of the specified JsonArray */ public static JsonArray unmodifiableArray(JsonArray array) { return new JsonArray(array, true); }
/** * Creates a new JsonArray that contains the JSON representations of the given strings. * * @param strings * the strings to be included in the new JSON array * @return a new JSON array that contains the given strings */ public static JsonArray array(String... strings) { if (strings == null) { throw new NullPointerException("values is null"); } JsonArray array = new JsonArray(); for (String value : strings) { array.add(value); } return array; }
/** * Creates a new JsonArray that contains the JSON representations of the given <code>double</code> * values. * * @param values * the values to be included in the new JSON array * @return a new JSON array that contains the given values */ public static JsonArray array(double... values) { if (values == null) { throw new NullPointerException("values is null"); } JsonArray array = new JsonArray(); for (double value : values) { array.add(value); } return array; }
/** * Creates a new JsonArray that contains the JSON representations of the given <code>int</code> * values. * * @param values * the values to be included in the new JSON array * @return a new JSON array that contains the given values */ public static JsonArray array(int... values) { if (values == null) { throw new NullPointerException("values is null"); } JsonArray array = new JsonArray(); for (int value : values) { array.add(value); } return array; }
/** * Creates a new JsonArray that contains the JSON representations of the given <code>long</code> * values. * * @param values * the values to be included in the new JSON array * @return a new JSON array that contains the given values */ public static JsonArray array(long... values) { if (values == null) { throw new NullPointerException("values is null"); } JsonArray array = new JsonArray(); for (long value : values) { array.add(value); } return array; }
/** * Creates a new JsonArray that contains the JSON representations of the given <code>float</code> * values. * * @param values * the values to be included in the new JSON array * @return a new JSON array that contains the given values */ public static JsonArray array(float... values) { if (values == null) { throw new NullPointerException("values is null"); } JsonArray array = new JsonArray(); for (float value : values) { array.add(value); } return array; }
/** * Creates a new JsonArray that contains the JSON representations of the given * <code>boolean</code> values. * * @param values * the values to be included in the new JSON array * @return a new JSON array that contains the given values */ public static JsonArray array(boolean... values) { if (values == null) { throw new NullPointerException("values is null"); } JsonArray array = new JsonArray(); for (boolean value : values) { array.add(value); } return array; }
private static JsonValue extractTimes(JsonArray measurements) { JsonArray result = new JsonArray(); for (JsonValue measurement : measurements) { result.add(measurement.asObject().get("processed")); } return result; }
private static JsonArray extractMeasurements(JsonObject caliperResults) { JsonArray result = new JsonArray(); JsonArray measurements = caliperResults.get("run").asObject().get("measurements").asArray(); for (JsonValue measurement : measurements) { result.add(extractMeasurement(measurement.asObject())); } return result; }
/** * Creates a new empty JsonArray. This is equivalent to creating a new JsonArray using the * constructor. * * @return a new empty JSON array */ public static JsonArray array() { return new JsonArray(); }
public JsonArray jSerialize(Collection<T> ts) { JsonArray o = new JsonArray(); if (ts != null) { for (T t : ts) { JsonObject jo = jSerialize(t); if (jo != null) o.add(jo); } } return o; }
/** * Util method for storing sha1 for parts being uploaded */ public void setPartsSha1(List<String> sha1s) { JsonArray jsonArray = new JsonArray(); for (String s : sha1s) { jsonArray.add(s); } set(FIELD_PARTS_SHA1, jsonArray); }
private String toJson(List<Measurement> ms, Map<String, String> tags) { final JsonArray items = new JsonArray(); for (Measurement m : ms) { if (!Double.isNaN(m.value()) && !Double.isInfinite(m.value())) { items.add(toJson(m, tags)); } } return items.toString(); }
@Override protected String createStringRepresentation() { final com.eclipsesource.json.JsonArray minimalJsonArray = new com.eclipsesource.json.JsonArray(); for (final JsonValue value : values) { minimalJsonArray.add(JsonFactory.convert(value)); } return minimalJsonArray.toString(); }
protected JsonObject buildSubscriptionObject() { JsonObject subscriptionObject = new JsonObject(); subscriptionObject.add("channelType", "httpLongPoll"); subscriptionObject.add("template", "raw"); JsonArray interestedResources = new JsonArray(); this.resources.forEach(interestedResources::add); subscriptionObject.add("interestedResources", interestedResources); return subscriptionObject; }
private static JsonObject getObject(SkypeImpl skype, String username) throws ConnectionException { JsonArray array = Endpoints.PROFILE_INFO .open(skype) .expect(200, "While getting contact info") .as(JsonArray.class) .post(new JsonObject() .add("usernames", new JsonArray() .add(username) ) ); return array.get(0).asObject(); }
@Override public void visit(CreateRequest request) { o.add("kind", "create"); o.add("contentFormat", request.getContentFormat().getCode()); if (request.getInstanceId() != null) o.add("instanceId", request.getInstanceId()); JsonArray resources = new JsonArray(); for (LwM2mResource resource : request.getResources()) { resources.add(LwM2mNodeSerDes.jSerialize(resource)); } o.add("resources", resources); }
@Override public void visit(CreateRequest request) { o.add("kind", "create"); o.add("contentFormat", request.getContentFormat().getCode()); if (request.getInstanceId() != null) o.add("instanceId", request.getInstanceId()); JsonArray resources = new JsonArray(); for (LwM2mResource resource : request.getResources()) { resources.add(LwM2mNodeSerDes.jSerialize(resource)); } o.add("resources", resources); }