Put document

Description

This command allows you to modify data at a given selector.
It generally works in the same way as put, but allows you to write entire documents with a single command.
Note that put document will completely overwrite any existing data at the given selector.

Usage

1
dasel put document -f <file> -d <document-parser> <selector> <document>
Copied!
Flag
Description
<document>
The document you want to put, as a marshaled/encoded string.
This is required.
-d, <document-parser>
Specify the parser to use when reading the document value.
If no value is provided, the read parser is used.
-f, --file
Specify the file to query. This is required unless you are piping in data.
If piping in data you can optionally pass -f stdin/-f -.
-o, --out
Specify the output file. If present, results will be written to the given file. If not present, results will be written to the input file (or stdout if none given).
To force output to be written to stdout, pass -o stdoutor-o -.
-r, --read
Specify the parser to use when reading the input data.
This is required if you are piping in data, otherwise dasel will use the given file extension to guess which parser to use.
-w, --write
Specify the parser to use when writing the output data.
If not provided dasel will attempt to use the --out and --read flags to determine which parser to use.
-p, --parser
Shorthand for -r <value> -w <value>
-m, --multiple
Tells dasel to put multiple items.
-s, --selector, <selector>
Specify the selector to use. See selectors for more information.
If no selector flag is given, dasel assumes the first argument given is the selector.
This is required.
-c, --compact
This tells dasel to output compact data where possible. E.g. not pretty printing JSON.
--merge-input-documents
--escape-html

Example

Put YAML document into JSON

1
echo '{"people":[]}' | dasel put document -p json -d yaml '.people.[]' 'name: Tom
2
colours:
3
- red
4
- green
5
- blue'
Copied!
1
{
2
"people": [
3
{
4
"colours": [
5
"red",
6
"green",
7
"blue"
8
],
9
"name": "Tom"
10
}
11
]
12
}
Copied!
Last modified 24d ago