Skip to main content
Appends one or more values to the end of a JSON array at the specified path.

Usage

Arguments

key
string
required
The key containing the JSON document
path
string
required
JSONPath expression pointing to the array to append to
values
...TData[]
required
One or more values to append to the array. Can be any JSON-serializable values.

Response

result
(number | null)[]
An array of numbers representing the new length of the array at each matching path. Returns null for paths that don’t exist or aren’t arrays.

Examples

Append single value to array

Append multiple values

Append to nested array

Append objects to array

Append to multiple arrays (wildcard path)

Handle non-existent paths

JSONPath Syntax

  • $.array - Append to a top-level array
  • $.nested.array - Append to a nested array
  • $.array[0].items - Append to array within array element
  • $..array - Append to all matching arrays recursively
  • $.items[*].tags - Append to arrays within each item

Notes

  • The path must point to an existing array. If the path doesn’t exist or points to a non-array value, null is returned for that path.
  • When using wildcard paths, the operation is performed on all matching arrays.
  • Values are automatically JSON-serialized before appending.

See Also