# Put object

## Description

This command allows you to modify data at a given selector.

It generally works in the same way as [put](/v1/usage/put.md), but allows you to write entire maps with a single command.

Note that `put object` will completely overwrite any existing data at the given selector.

## Usage

```shell
dasel put object -f <file> -t <type> -t <type> <selector> <value:key=value> <value:key=value>
```

{% hint style="info" %}
Omit the types and values to create an empty object/map.
{% endhint %}

| Flag                             | Description                                                                                                                                                                                                                                                                     |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `-t`, `<type>`                   | <p>The type of value you want to put.</p><p>You must repeat this argument for each value provided.</p><p>Available arguments:</p><ul><li>string</li><li>int</li><li>bool</li></ul>                                                                                              |
| `<value>`                        | <p>The key + value to write as<code>key=value</code></p><p>Dasel will parse this value as a string, int, or bool depending on the given <code>type</code>.</p><p>This is required.</p>                                                                                          |
| `-f`, `--file`                   | <p>Specify the file to query. This is required unless you are piping in data.</p><p>If piping in data you can optionally pass <code>-f stdin</code>/<code>-f -</code>.</p>                                                                                                      |
| `-o`, `--out`                    | <p>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).</p><p>To force output to be written to stdout, pass <code>-o stdout</code>or<code>-o -</code>.</p>      |
| `-r`, `--read`                   | <p>Specify the parser to use when reading the input data.</p><p>This is required if you are piping in data, otherwise dasel will use the given file extension to guess which parser to use.</p><p>See <a href="/pages/-MXgNylC4AkvSj351jU3">supported file types</a>.</p>       |
| `-w`, `--write`                  | <p>Specify the parser to use when writing the output data.</p><p>If not provided dasel will attempt to use the <code>--out</code> and <code>--read</code> flags to determine which parser to use.</p><p>See <a href="/pages/-MXgNylC4AkvSj351jU3">supported file types</a>.</p> |
| `-p`, `--parser`                 | Shorthand for `-r <value> -w <value>`                                                                                                                                                                                                                                           |
| `-m`, `--multiple`               | <p>Tells dasel to put multiple items.</p><p>See <a href="/pages/-MXgNylAqqL66l3g7A2u">multiple</a>.</p>                                                                                                                                                                         |
| `-s`, `--selector`, `<selector>` | <p>Specify the selector to use. See <a href="/pages/-MXgNylFbABKYJMirPOA">selectors</a> for more information.</p><p>If no selector flag is given, dasel assumes the first argument given is the selector.</p><p>This is required.</p>                                           |
| `--plain`                        | <p>By default, dasel formats the output using the specified parser.</p><p>If this flag is used no formatting occurs and the results output as a string.</p>                                                                                                                     |
| `-c`, `--compact`                | This tells dasel to output compact data where possible. E.g. not pretty printing JSON.                                                                                                                                                                                          |
| `--merge-input-documents`        | See [merge input documents](/v1/usage/flags/merge-input-documents.md).                                                                                                                                                                                                          |
| `--escape-html`                  | See [escape html](/v1/usage/flags/escape-html.md).                                                                                                                                                                                                                              |

## Example

### Put object

```shell
$ echo "" | dasel put object -p yaml -t string -t int "my.favourites" colour=red number=3
my:
  favourites:
    colour: red
    number: 3
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://daseldocs.tomwright.me/v1/usage/put-object.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
