Interface JsonOperations.JsonArraySpec

All Superinterfaces:
JsonOperations.PathSpec<JsonOperations.JsonArraySpec>
Enclosing interface:
JsonOperations<K>

public static interface JsonOperations.JsonArraySpec extends JsonOperations.PathSpec<JsonOperations.JsonArraySpec>
Specification for JSON array operations bound to a particular key.

All commands invoked through this interface operate on a JSON path defaulting to the document root ($).

Since:
4.2
Author:
Mark Paluch, Yordan Tsintsov, Moritz Halbritter
  • Method Details

    • append

      default List<@Nullable Long> append(Object... values)
      Append the given values to the JSON array at the configured path.
      Parameters:
      values - the values to append, must not be empty or null.
      Returns:
      the new array length for each matching path.
      See Also:
    • append

      List<@Nullable Long> append(Collection<? extends Object> values)
      Append the given values to the JSON array at the configured path.
      Parameters:
      values - the values to append, must not be empty or null.
      Returns:
      the new array length for each matching path.
      See Also:
    • length

      List<@Nullable Long> length()
      Return the length of the JSON array at the configured path.
      Returns:
      the array length for each matching path.
      See Also:
    • trim

      List<@Nullable Long> trim(int start, int end)
      Trim the JSON array to the inclusive range between start and end.
      Parameters:
      start - the index of the first element to keep.
      end - the index of the last element to keep. Negative values count from the end.
      Returns:
      the new array length for each matching path.
      See Also:
    • indexOf

      List<@Nullable Long> indexOf(Object value)
      Return the first index of value within the JSON array at the configured path.
      Parameters:
      value - the value to find.
      Returns:
      a list where each element contains the index of the first occurrence of the value, -1 if not found, or null if the matched value is not an array. Returns an empty list if the path does not match any value.
      See Also:
    • index

      Select an array element by its index for subsequent operations.
      Parameters:
      index - the array index to operate on.
      Returns:
      a spec for index-based array operations.