On , I learnt ...

About jq’s --slurp option

Problem: you want to find the unique values of a key in some JSON Lines input using jq.

JQ’s unique function requires an array as input and so we must convert the separate JSON objects from the JSONL steam into an array. This is done using the --slurp option:

jq slurp docs

Example usage:

# Find unique workspace names
$ cat workspaces.jsonl | jq --slurp '[.[].workspace_name] | unique'

where [.[].workspace_name] creates an array of all .workspace_name keys from each object in the JSONL stream.