@Override public JsonArray build() { return ImmutableJsonArray.of(values); }
/** * Returns a new JSON array which is based on the given JSON array of the Minimal Json project library. * * @param values the values to base the JSON array to be created on. * @return a new JSON array. * @throws NullPointerException if {@code values} is {@code null}. */ public static ImmutableJsonArray of(final List<JsonValue> values) { return of(values, null); }
@Override public JsonArray build() { return ImmutableJsonArray.of(values); }
@Override public void endArray(final List<JsonValue> jsonValues) { final StringBuilder stringBuilder = stringBuilders.poll(); if (null != stringBuilder) { if (!jsonValues.isEmpty()) { stringBuilder.deleteCharAt(stringBuilder.length() - 1); } stringBuilder.append(']'); valueString = stringBuilder.toString(); } jsonValue = ImmutableJsonArray.of(jsonValues, valueString); }
@Override public ImmutableJsonArray add(final JsonValue value, final JsonValue... furtherValues) { checkValue(value); checkFurtherValues(furtherValues); final List<JsonValue> valuesCopy = copyValues(); valuesCopy.add(value); Collections.addAll(valuesCopy, furtherValues); return of(valuesCopy); }
/** * Creates a new JSON array from the given string. * * @param jsonString the string that represents the JSON array. * @return the JSON array that has been created from the string. * @throws NullPointerException if {@code jsonString} is {@code null}. * @throws IllegalArgumentException if {@code jsonString} is empty. * @throws JsonParseException if {@code jsonString} does not contain a valid JSON array. */ public static JsonArray newArray(final String jsonString) { requireNonNull(jsonString, "The JSON string to create JSON array from must not be null!"); if (jsonString.isEmpty()) { throw new IllegalArgumentException("The JSON string to create a JSON array from must not be empty!"); } if (jsonString.equals(Json.NULL.toString())) { return NULL_JSON_ARRAY; } else { final com.eclipsesource.json.JsonArray jsonArray = tryToReadMinimalJsonArrayFrom(jsonString); return ImmutableJsonArray.of(toList(jsonArray)); } }
@Override public ImmutableJsonArray add(final boolean value, final boolean... furtherValues) { checkFurtherValues(furtherValues); final List<JsonValue> valuesCopy = copyValues(); valuesCopy.add(JsonFactory.newValue(value)); for (final boolean furtherValue : furtherValues) { valuesCopy.add(JsonFactory.newValue(furtherValue)); } return of(valuesCopy); }
} else if (minimalJsonValue.isArray()) { final List<JsonValue> jsonValues = toList(minimalJsonValue.asArray()); result = ImmutableJsonArray.of(jsonValues); } else if (minimalJsonValue.isBoolean()) { result = newValue(minimalJsonValue.asBoolean());