Dasel
v3
v3
  • Getting started
    • Introduction
    • Installation
    • Concepts
      • Expressions
      • Branches
  • Syntax
    • Whitespace
    • Types/Literals
    • String concatenation
    • Arrays/slices
    • Objects/maps
    • Conditionals
    • Spread
    • Coalesce
  • Input/Output
    • Read/Write formats
    • Stdin
    • Stdout
    • Variables
    • Read/Writer flags
  • Functions
    • add
    • min
    • max
    • reverse
    • toString
    • toInt
    • toFloat
    • typeOf
    • map
    • filter
    • sortBy
    • parse
    • base64e
    • base64d
Powered by GitBook
On this page
  1. Getting started
  2. Concepts

Branches

This feature is potentially unstable. Must be used with the --unstable flag.

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

This documentation is a little light, but will be improved with time.

Examples

Without branching

When we don't branch, notice how the result is an array containing numbers.

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

Branching on numbers

When we branch on the numbers, we actually get separate JSON documents out at the end.

$ cat numbers.json | dasel -i json 'branch(numbers...)'
{
    "x": 1
}
{
    "x": 2
}
{
    "x": 3
}

Filtering on a branch

Since filter must be used on arrays and a branch isn't technically an array, we can instead use ignore. This marks a specific branch as irrelevant and it will be stripped from the result.

[1,2,3].branch().if ( $this==2 ) { ignore() } else { $this }
2
3

PreviousExpressionsNextWhitespace

Last updated 7 months ago