@Override public void endArrayValue(JsonArray array) { array.add(value); }
/** * 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; }
private void assureJsonArraySize(JsonArray jsonArray, Integer index) { while (index >= jsonArray.size()) { jsonArray.add(Json.NULL); } }
private void assureJsonArraySize(JsonArray jsonArray, Integer index) { while (index >= jsonArray.size()) { jsonArray.add(Json.NULL); } }
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; }
@SuppressWarnings("unchecked") @Override public JsonValue write(Object value) throws Exception { JsonArray array = (JsonArray) Json.array(); T[] arrayValues = (T[]) value; for (int i = 0; i < arrayValues.length; i++) { array.add(setValue(arrayValues[i])); } return array; }
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(); }
String encode(Iterable<RequestLimitRule> rules) { JsonArray jsonArray = Json.array().asArray(); rules.forEach(rule -> jsonArray.add(toJsonArray(rule))); return jsonArray.toString(); }
@Override public com.eclipsesource.json.JsonValue minimaljson(Users obj) throws IOException { com.eclipsesource.json.JsonObject jso = com.eclipsesource.json.Json.object(); if (obj.users != null) { com.eclipsesource.json.JsonArray jsarr = (com.eclipsesource.json.JsonArray) com.eclipsesource.json.Json.array(); for (User u : obj.users) { jsarr.add(minimaljson(u)); } jso.add("users", jsarr); } return jso; }
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); }