# $ifNull

`$ifNull` operator checks if the condition resolves to `null` (or `None`) and returns you the item based on the condition passed in the object. You can use this in any [**Expression Object**](https://docs.cosmocloud.io/flow-builder/cql-cosmocloud-query-language/building-expressions).

## Syntax

```json
{
    "$ifNull": [ <expr>, <true_val>, <default> ]
}
```

### Properties

| Field        | Description                                                                                                                                                                                         | Required |
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| \<expr>      | <p>The <code>\<expr></code> expression can be any valid <a href=""><mark style="color:blue;"><strong>expression object</strong></mark></a>.</p><p></p><p>It can also be a Magical Autocomplete.</p> | true     |
| \<true\_val> | <p>The value to return if the <code>\<expr></code> is found to be <code>null</code> (or <code>None</code>).<br><br>It can also be a Magical Autocomplete.</p>                                       | true     |
| \<default>   | <p>The value to return if the <code>\<expr></code> is not found to be <code>null</code> (or <code>None</code>)<br><br>It can also be a Magical Autocomplete.</p>                                    | true     |

### Returns

`<object>` - Returns either the `<true_val>` or `<default>` based on the expr. The object type can be anything based on the values provided.

## Examples

### With Magical Autocomplete

Let's say we have declared a variable `country` in our API flow, which has a `null` value currently.

```json
{
    "$ifNull": [ 
        "$.variables.country",
        "US",
        "India"
    ]
}
```

The above expression returns **US** as the expr resolves to `null`.
