# OrDefault

Accepts 2 arguments.

Or default allows you to use another value or selector as a backup when the expected value isn't present.

## Examples

### Simple field selection

```
$ echo '{"name":"Tom","email":"contact@tomwright.me"}' | dasel -r json 'orDefault(phone,string(N/A))'           
"N/A"
```

### Creating a new map with defaults

```
$ echo '[
  {
    "name": "Tom",
    "email": "contact@tomwright.me"
  },
  {
    "name": "Jim",
    "phone": "+441234567890"
  }
]' | go run cmd/dasel/main.go -r json 'all().mapOf(name,name,email,orDefault(email,string(N/A)),phone,orDefault(phone,string(N/A)))'           
{
  "email": "contact@tomwright.me",
  "name": "Tom",
  "phone": "N/A"
}
{
  "email": "N/A",
  "name": "Jim",
  "phone": "+441234567890"
}

```


---

# 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/v2/functions/ordefault.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.
