Dasel
v2
v2
  • Introduction
  • GitHub
  • Supported file formats
  • Memory usage
  • Installation
  • Commands
    • Select
    • Put
    • Delete
  • Functions
    • Selector Overview
    • All
    • And
    • Append
    • Count
    • Equal
    • Filter
    • FilterOr
    • First
    • Index
    • Join
    • Key
    • Keys
    • Last
    • Len
    • LessThan
    • MapOf
    • Merge
    • MoreThan
    • Not
    • Or
    • OrDefault
    • Parent
    • Property
    • String
    • Null
    • This
    • Type
  • Examples
    • Using dasel as a go package
    • Basics
    • Change file format
    • Filtering objects based on present/missing key
Powered by GitBook
On this page
  • No arguments
  • 1 or more arguments
  • Examples
  • Merge arguments
  • Merge no arguments
Edit on GitHub
  1. Functions

Merge

Merge expect 0 or more arguments.

No arguments

When called with no arguments merge takes all of the output values from the previous function and adds them to a single list.

1 or more arguments

When called with 1 or more arguments, the arguments are executed as a subquery on each of the output values from the previous function.

All values returned from subqueries across all input values are added to a single list.

Examples

Merge arguments

$ echo '{
  "name": {
    "first":"Tom",
    "last":"Wright"
  },
  "firstNames": [
    "Jim",
    "Bob"
  ]
}' | dasel -r json 'merge(name.first,firstNames.all()).all()' 
[
  "Tom",
  "Jim",
  "Bob"
]

Merge no arguments

$ echo '[
  {"name": {"first": "Tom"}},
  {"name": {"first": "Jim"}},
  {"name": {"first": "Frank"}}
]' | dasel -r json 'all().name.first.merge()' 
[
  "Tom",
  "Jim",
  "Frank"
]
PreviousMapOfNextMoreThan

Last updated 2 years ago