π
π
π
π
Dasel
Searchβ¦
π
π
π
π
Dasel
Introduction
Installation
Use as a go package
Github
Playground
Usage
Select
Put
Put object
Put document
Delete
Validate
Flags
Supported file types
Selectors
Introduction
Property
Keys and indexes
Index
Next Available Index
All indexes
Dynamic
Search
Search Optional
Length
Type
Notes
File formatting and ordering
Memory usage
Converting between formats
Examples
JQ to Dasel
YQ to Dasel
XML
Filter JSON API results
Powered By
GitBook
YQ to Dasel
The follow examples show a set of
yq
commands and the equivalent in dasel.
Select a single value
YQ
Dasel
echo
'name: Tom'
|
yq
'.name'
"Tom"
echo
'name: Tom'
|
dasel -p yaml
'.name'
Tom
Select a nested value
YQ
Dasel
echo
'user:
name: Tom
age: 27'
|
yq
'.user.age'
27
echo
'user:
name: Tom
age: 27'
|
dasel -p yaml
'.user.age'
27
Select an array index
YQ
Dasel
echo
'- 1
- 2
- 3'
|
yq
'.[1]'
2
echo
'- 1
- 2
- 3'
|
dasel -p yaml
'.[1]'
2
Append to an array of strings
YQ
Dasel
echo
'- a
- b
- c'
|
yq --yaml-output
'. += ["d"]'
- a
- b
- c
- d
echo
'- a
- b
- c'
|
dasel put string -p yaml -s
'.[]'
d
- a
- b
- c
- d
Update a string value
YQ
Dasel
echo
'- a
- b
- c'
|
yq --yaml-output
'.[1] = "d"'
- a
- d
- c
echo
'- a
- b
- c'
|
dasel put string -p yaml -s
'.[1]'
d
- a
- d
- c
Update an int value
YQ
Dasel
echo
'- 1
- 2
- 3'
|
yq --yaml-output
'.[1] = 5'
-
1
-
5
-
3
echo '- 1
- 2
- 3' | dasel put int -p yaml -s '.[1]' 5
- 1
- 5
- 3
Overwrite an object
YQ
Dasel put object
Dasel put document
echo
'user:
name: Tom
age: 27'
|
yq --yaml-output
'.user = {"name": "Frank", "age": 25}'
user:
name: Frank
age:
25
echo
'user:
name: Tom
age: 27'
|
dasel put object -p yaml -t string -t int
'.user'
name
=
Frank
age
=
25
user:
age:
25
name: Frank
echo
'user:
name: Tom
age: 27'
|
dasel put document -p yaml -d json
'.user'
'{"name":"Frank","age":25}'
user:
age:
25
name: Frank
Append to an array of objects
YQ
Dasel put object
Dasel put document
echo
'users:
- name: Tom'
|
yq --yaml-output
'.users += [{"name": "Frank"}]'
users:
- name: Tom
- name: Frank
echo
'users:
- name: Tom'
|
dasel put object -p yaml -t string
'.users.[]'
name
=
Frank
users:
- name: Tom
- name: Frank
echo
'users:
- name: Tom'
|
dasel put document -p yaml -d json
'.users.[]'
'{"name":"Frank"}'
users:
- name: Tom
- name: Frank
Examples - Previous
JQ to Dasel
Next - Examples
XML
Last modified
1mo ago
Copy link
Edit on GitHub
Outline
Select a single value
Select a nested value
Select an array index
Append to an array of strings
Update a string value
Update an int value
Overwrite an object
Append to an array of objects