> 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/v2/functions/mapof.md).

# MapOf

Expects 2 or more arguments.

Expects arguments to be given in pairs, where the first argument is the property name, and the second argument is a selector that will be used to resolve the property value.

## Examples

### Filtering values into lists

```
$ echo '[1,2,3,4,5]' | 
  dasel -r json 'mapOf(lessThan,all().filter(lessThan(.,3)).merge(),moreThan,all().filter(moreThan(.,3)).merge())'
{
  "lessThan": [
    1,
    2
  ],
  "moreThan": [
    4,
    5
  ]
}

```

### Restructuring/picking specific fields

```
$ echo '[
  {
    "name": {
      "first": "Tom",
      "last": "Wright"
    },
    "title": "Mr",
    "phone": "07"
  },
  {
    "name": {
      "first": "Joe",
      "last": "Bloggs"
    },
    "title": "Mr",
    "phone": "07"
  }
]' | dasel -r json 'all().mapOf(firstName,name.first,lastName,name.last,title,title,phone,phone).merge()'
[
  {
    "firstName": "Tom",
    "lastName": "Wright",
    "phone": "07",
    "title": "Mr"
  },
  {
    "firstName": "Joe",
    "lastName": "Bloggs",
    "phone": "07",
    "title": "Mr"
  }
]
```

### Exporting specific fields to csv

```
$ echo '[
  {
    "name": {
      "first": "Tom",
      "last": "Wright"
    },
    "title": "Mr",
    "phone": "07"
  },
  {
    "name": {
      "first": "Joe",
      "last": "Bloggs"
    },
    "title": "Mr",
    "phone": "07"
  }
]' | dasel -r json -w csv 'all().mapOf(phone,phone,firstName,name.first).merge()'
firstName,phone
Tom,07
Joe,07
```


---

# 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:

```
GET https://daseldocs.tomwright.me/v2/functions/mapof.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.
