Skip to main content

module  pixeltable.functions.json

Pixeltable UDFs for JsonType. Example:

iterator  list_iterator()

Signature
Iterator over elements of a list or lists. There are two distinct call patterns: either a single positional argument; or one or more keyword arguments.
  • If a single positional argument is specified, as in list_iterator(t.col), then the elements of t.col must contain lists of dictionaries with matching signatures (identical keys and compatible value types). The iterator will yield one new column for each key in the dictionaries, and one output row per element in the lists.
  • If multiple keyword arguments are specified, as in list_iterator(val_1=t.col_1, val_2=t.col_2), then the elements of each input column must contain lists, but not necessarily lists of dictionaries. The iterator will yield one new column for each keyword argument, zipping together the individual lists.
All of the inputs must be typed Json expressions. Untyped Json will be rejected (the type schema is necessary in order for Pixeltable to determine the types of the output columns). Parameters:
  • elements (pxt.Json[(Json): A list of dictionaries to iterate over. The dictionary keys will be used as column names in the output. Cannot be specified together with keyword arguments.
  • mode (Any): Only applies when called with keyword arguments. Determines how to handle lists of different lengths:
    • 'strict': Raises an error if the input lists have different lengths.
    • 'truncated': Iterates until the shortest input list is exhausted, ignoring any remaining elements in longer lists.
    • 'padded': Iterates until the longest input list is exhausted, yielding None for any missing elements from shorter lists.
  • **kwargs (Any): One or more lists to iterate over. The kwarg names will be used as column names in the output. Cannot be specified together with elements.

uda  make_list()

Signature
Collects arguments into a list.

udf  concat()

Signature
Concatenate two JSON arrays into a new array. Returns null if either operand is null. Raises if either operand is a non-null, non-array value. Examples:

udf  contains()

Signature
Return True if value is an element of a JSON array or a key of a JSON object; False otherwise. Examples:

udf  count()

Signature
Return the number of times value occurs in a JSON array. Examples:

udf  dumps()

Signature
Serialize a JSON object to a string. Equivalent to json.dumps(). Parameters:
  • obj (pxt.Json): A JSON-serializable object (dict, list, or scalar).
Returns:
  • pxt.String: A JSON-formatted string.

udf  flatten()

Signature
Concatenate the elements of a JSON array one level deep; non-array elements are kept as-is. Examples:

udf  get()

Signature
Return the value of key if the value is a JSON object containing it, otherwise default. Examples:

udf  is_empty()

Signature
Return True if the value is null, an empty array, an empty object, or an empty string; False otherwise (including for numbers and booleans). Examples:

udf  items()

Signature
Return the [key, value] pairs of a JSON object as a list. keys(), values(), and items() share the same ordering. Examples:

udf  keys()

Signature
Return the keys of a JSON object. keys(), values(), and items() share the same ordering. Examples:

udf  len()

Signature
Return the number of elements in a JSON array, keys in a JSON object, or characters in a JSON string. Not defined for numbers or booleans. A null value (or missing path) yields null. Examples:

udf  max()

Signature
Return the largest number in a JSON array, or null if the array is empty. Examples:

udf  mean()

Signature
Return the arithmetic mean of the numbers in a JSON array, or null if the array is empty. Examples:

udf  merge()

Signature
Merge two JSON objects into a new object; on a key conflict the value from other wins. Returns null if either operand is null. Raises if either operand is a non-null, non-object value. Examples:

udf  min()

Signature
Return the smallest number in a JSON array, or null if the array is empty. Examples:

udf  sum()

Signature
Return the sum of the numbers in a JSON array (0 for an empty array). Examples:

udf  values()

Signature
Return the values of a JSON object. keys(), values(), and items() share the same ordering. Examples:
Last modified on July 20, 2026