> For the complete documentation index, see [llms.txt](https://daseldocs.tomwright.me/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://daseldocs.tomwright.me/functions/mapvalues.md).

# mapValues

The `mapValues` function transforms all values of a map/object while preserving its keys. It is the map/object counterpart to [`map`](/functions/map.md), which operates on arrays.

#### Syntax

```
<object>.mapValues(expr)
```

#### Arguments

* **expr** - An expression evaluated against each value. Use `$this` to refer to the current value and `$key` to refer to the current key name.

#### Examples

**Double all values**

```
{"a": 1, "b": 2, "c": 3}.mapValues($this * 2)
// {"a": 2, "b": 4, "c": 6}
```

**Boolean expression**

```
{"a": 3, "b": 8}.mapValues($this > 5)
// {"a": false, "b": true}
```

**Transform strings**

```
{"x": "hello", "y": "world"}.mapValues(toUpper())
// {"x": "HELLO", "y": "WORLD"}
```

**Replace values with their key names using `$key`**

```
{"a": 1, "b": 2}.mapValues($key)
// {"a": "a", "b": "b"}
```

**CLI usage**

```bash
$ echo '{"a":1,"b":2}' | dasel 'mapValues($this * 2)'
{
    "a": 2,
    "b": 4
}
```

**Chained with property access**

```
{"a": 1, "b": 2}.mapValues($this + 10).a
// 11
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://daseldocs.tomwright.me/functions/mapvalues.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
