For the complete documentation index, see llms.txt. This page is also available as Markdown.

Branches

Dasel includes the concept of branches. branch allows you to perform one or more sub queries, with each query output as a separate document.


Without branching

When we don't branch, the result is an array containing the items.

Given numbers.json:

{ "numbers": [{"x": 1}, {"x": 2}, {"x": 3}] }
$ cat numbers.json | dasel -i json 'numbers'
[
    {
        "x": 1
    },
    {
        "x": 2
    },
    {
        "x": 3
    }
]

Branching on an array

When we branch, each element is output as a separate document instead of a single array.


Filtering branches with ignore

Since filter operates on arrays and a branch isn't technically an array, you can use ignore to exclude specific branches from the result.

Here, the element 2 is matched by the condition and ignore() removes it from the output. The remaining elements 1 and 3 are output as separate documents.


Extracting multiple fields as separate documents


Notes

  • branch converts an array (or multiple values) into separate output documents.

  • Use the spread operator (...) to unpack an array into branch arguments.

  • Use ignore to conditionally exclude branches.

Last updated