Skip to content

jq Operators

pdum.plumbum.jq

Attributes

JsonArray module-attribute

JsonArray = list['JsonValue'] | tuple['JsonValue', ...]

JsonObject module-attribute

JsonObject = dict[str, 'JsonValue']

JsonScalar module-attribute

JsonScalar = str | int | float | bool | None

JsonValue module-attribute

JsonValue = JsonScalar | JsonArray | JsonObject

PathElement module-attribute

PathElement = str | int

PathToken module-attribute

PathToken = Field | Index | FieldWildcard | IndexWildcard

ResolvedPath module-attribute

ResolvedPath = Tuple[PathElement, ...]

__all__ module-attribute

__all__ = [
    "Field",
    "FieldWildcard",
    "Index",
    "IndexWildcard",
    "JsonArray",
    "JsonObject",
    "JsonScalar",
    "JsonValue",
    "PathElement",
    "PathSyntaxError",
    "PathToken",
    "ResolvedPath",
    "apply_path",
    "coalesce",
    "contains",
    "count_by",
    "delete_path",
    "ensure_resolved_path",
    "explode",
    "field",
    "flatten",
    "get_path",
    "group_by",
    "iter_paths",
    "keys",
    "match",
    "merge",
    "parse_path",
    "pick",
    "pluck",
    "project",
    "remove",
    "resolve_path",
    "set_path",
    "set_value",
    "stats",
    "sum_by",
    "transform",
    "transform_path",
    "unwind",
    "values",
    "walk",
    "walk_tree",
    "aexplode",
    "aunwind",
    "agroup_by",
    "acount_by",
    "asum_by",
    "astats",
    "where_equals",
    "where_exists",
    "where_type",
    "zip_fields",
]

Classes

Field dataclass

Attributes
name instance-attribute
name

FieldWildcard dataclass

Index dataclass

Attributes
index instance-attribute
index

IndexWildcard dataclass

PathSyntaxError

Bases: ValueError

Raised when a path expression cannot be parsed.

Functions

acount_by async

acount_by(stream, expr)

aexplode async

aexplode(iterator, expr, keep_path=False)

agroup_by async

agroup_by(stream, expr)

apply_path

apply_path(value, path, func)

astats async

astats(stream, expr)

asum_by async

asum_by(stream, key_expr, value_expr, *, default=0.0)

aunwind async

aunwind(iterator, expr, keep_empty=False)

coalesce

coalesce(value, *exprs, default=None)

contains

contains(value, expr, needle)

count_by

count_by(iterable, expr)

delete_path

delete_path(value, path)

ensure_resolved_path

ensure_resolved_path(path)

explode

explode(value, expr, *, keep_path=False)

field

field(value, expr, *, default=None, multi=False, raise_on_missing=False)

flatten

flatten(value, expr=None)

get_path

get_path(value, path, default=None)

group_by

group_by(iterable, expr)

iter_paths

iter_paths(value, path)

keys

keys(value, expr=None)

match

match(value, expr, pattern)

merge

merge(value, *exprs)

parse_path

parse_path(expression)

Parse a dotted path expression into path tokens.

Supported syntax: - foo.bar: field access - items[0]: numeric index - items[] or []: index wildcard - *: field wildcard - Optional leading . is ignored

pick

pick(value, *keys, default=_DEFAULT, **aliases)

pluck

pluck(value, *exprs, as_dict=False, **named_exprs)

project

project(value, expr, pipeline)

remove

remove(value, expr)

resolve_path

resolve_path(value, path)

set_path

set_path(value, path, new_value)

set_value

set_value(value, expr, replacement)

stats

stats(iterable, expr)

sum_by

sum_by(iterable, key_expr, value_expr, *, default=0.0)

transform

transform(value, expr, pipeline)

transform_path

transform_path(value, path, func)

unwind

unwind(value, expr, *, keep_empty=False)

values

values(value, expr=None)

walk

walk(value, expr, pipeline)

walk_tree

walk_tree(value)

where_equals

where_equals(value, expr, expected)

where_exists

where_exists(value, expr)

where_type

where_type(value, expr, expected_type)

zip_fields

zip_fields(value, *exprs, strict=False)

Modules

async_operators

Attributes
Functions
acount_by async
acount_by(stream, expr)
aexplode async
aexplode(iterator, expr, keep_path=False)
agroup_by async
agroup_by(stream, expr)
astats async
astats(stream, expr)
asum_by async
asum_by(stream, key_expr, value_expr, *, default=0.0)
aunwind async
aunwind(iterator, expr, keep_empty=False)
Modules

operators

Attributes
Classes
Functions
coalesce
coalesce(value, *exprs, default=None)
contains
contains(value, expr, needle)
count_by
count_by(iterable, expr)
explode
explode(value, expr, *, keep_path=False)
field
field(value, expr, *, default=None, multi=False, raise_on_missing=False)
flatten
flatten(value, expr=None)
group_by
group_by(iterable, expr)
keys
keys(value, expr=None)
match
match(value, expr, pattern)
merge
merge(value, *exprs)
pick
pick(value, *keys, default=_DEFAULT, **aliases)
pluck
pluck(value, *exprs, as_dict=False, **named_exprs)
project
project(value, expr, pipeline)
remove
remove(value, expr)
set_value
set_value(value, expr, replacement)
stats
stats(iterable, expr)
sum_by
sum_by(iterable, key_expr, value_expr, *, default=0.0)
transform
transform(value, expr, pipeline)
unwind
unwind(value, expr, *, keep_empty=False)
values
values(value, expr=None)
walk
walk(value, expr, pipeline)
where_equals
where_equals(value, expr, expected)
where_exists
where_exists(value, expr)
where_type
where_type(value, expr, expected_type)
zip_fields
zip_fields(value, *exprs, strict=False)

paths

Attributes
T module-attribute
T = TypeVar('T')
Classes
PathSyntaxError

Bases: ValueError

Raised when a path expression cannot be parsed.

Functions
apply_path
apply_path(value, path, func)
delete_path
delete_path(value, path)
get_path
get_path(value, path, default=None)
iter_paths
iter_paths(value, path)
normalize_path
normalize_path(path)
parse_path
parse_path(expression)

Parse a dotted path expression into path tokens.

Supported syntax: - foo.bar: field access - items[0]: numeric index - items[] or []: index wildcard - *: field wildcard - Optional leading . is ignored

resolve_path
resolve_path(value, path)
set_path
set_path(value, path, new_value)
transform_path
transform_path(value, path, func)
walk_tree
walk_tree(value)

typing

Attributes
JsonArray module-attribute
JsonArray = list['JsonValue'] | tuple['JsonValue', ...]
JsonObject module-attribute
JsonObject = dict[str, 'JsonValue']
JsonScalar module-attribute
JsonScalar = str | int | float | bool | None
JsonValue module-attribute
JsonValue = JsonScalar | JsonArray | JsonObject
PathElement module-attribute
PathElement = str | int
PathToken module-attribute
PathToken = Field | Index | FieldWildcard | IndexWildcard
ResolvedPath module-attribute
ResolvedPath = Tuple[PathElement, ...]
Classes
Field dataclass
Attributes
name instance-attribute
name
FieldWildcard dataclass
Index dataclass
Attributes
index instance-attribute
index
IndexWildcard dataclass
Functions
ensure_resolved_path
ensure_resolved_path(path)