/** * 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); }
/** * 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); }
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; }
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; }
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; }