/** * 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); }
/** * Appends the JSON representation of the specified <code>double</code> value to the end of this * array. * * @param value * the value to add to the array * @return the array itself, to enable method chaining */ public JsonArray add(double value) { values.add(valueOf(value)); return this; }
public JsonObject asJson() { JsonObject json = new JsonObject(); json.add("max", maxPlayers); json.add("online", onlinePlayers); JsonArray sampleArray = new JsonArray(); for (ServerPingResponseSample sample : samples) { if (sample != null) { sampleArray.add(sample.asJson()); } } json.add("sample", sampleArray); return json; }
private JsonArray readArray() throws IOException { read(); JsonArray array=new JsonArray(); skipWhiteSpace(); if (readIf(']')) { return array; } do { skipWhiteSpace(); array.add(readValue()); skipWhiteSpace(); } while (readIf(',')); if (!readIf(']')) { throw expected("',' or ']'"); } return array; }
private JsonArray readArray() throws IOException { read(); JsonArray array=new JsonArray(); skipWhiteSpace(); if (readIf(']')) { return array; } do { skipWhiteSpace(); array.add(readValue()); skipWhiteSpace(); } while (readIf(',')); if (!readIf(']')) { throw expected("',' or ']'"); } return array; }
/** * Appends the JSON representation of the specified <code>boolean</code> value to the end of this * array. * * @param value * the value to add to the array * @return the array itself, to enable method chaining */ public JsonArray add(boolean value) { values.add(valueOf(value)); return this; }
/** * 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); }
private JsonArray readArray() throws IOException { read(); JsonArray array=new JsonArray(); skipWhiteSpace(); if (readIf(']')) { return array; } while (true) { skipWhiteSpace(); array.add(readValue()); skipWhiteSpace(); if (readIf(',')) skipWhiteSpace(); // , is optional if (readIf(']')) break; else if (isEndOfText()) throw error("End of input while parsing an array (did you forget a closing ']'?)"); } return array; }
/** * Appends the JSON representation of the specified <code>int</code> value to the end of this * array. * * @param value * the value to add to the array * @return the array itself, to enable method chaining */ public JsonArray add(int value) { values.add(valueOf(value)); return this; }
if (with != null) { JsonArray array = with.asArray(); for (int i = 0, j = array.size(); i < j; i++) { JsonValue el = array.get(i); if (el.isString() || el.isNumber() || el.isBoolean()) cc.addWith(el.asString()); if (extra != null) { JsonArray array = extra.asArray(); for (int i = 0, j = array.size(); i < j; i++) { JsonValue el = array.get(i); if (el.isString() || el.isNumber() || el.isBoolean()) cc.addExtra(el.asString());
/** * Appends the JSON representation of the specified <code>boolean</code> value to the end of this * array. * * @param value * the value to add to the array * @return the array itself, to enable method chaining */ public JsonArray add(boolean value) { values.add(valueOf(value)); return this; }
private JsonArray readArray() throws IOException { read(); JsonArray array=new JsonArray(); skipWhiteSpace(); if (readIf(']')) { return array; } while (true) { skipWhiteSpace(); array.add(readValue()); skipWhiteSpace(); if (readIf(',')) skipWhiteSpace(); // , is optional if (readIf(']')) break; else if (isEndOfText()) throw error("End of input while parsing an array (did you forget a closing ']'?)"); } return array; }
/** * Appends the JSON representation of the specified <code>float</code> value to the end of this * array. * * @param value * the value to add to the array * @return the array itself, to enable method chaining */ public JsonArray add(float value) { values.add(valueOf(value)); return this; }
/** * Appends the JSON representation of the specified <code>long</code> value to the end of this * array. * * @param value * the value to add to the array * @return the array itself, to enable method chaining */ public JsonArray add(long value) { values.add(valueOf(value)); return this; }