---
title: Null safe usage
description: Using property references that might be null in expressions can lead to unexpected results. This topic contains examples and how to handle them.
component: pingone
page_id: pingone:pingone_expression_language:p1_expressionlang_null_safe_usage
canonical_url: https://docs.pingidentity.com/pingone/pingone_expression_language/p1_expressionlang_null_safe_usage.html
revdate: May 3, 2024
section_ids:
  string-concatenation: String concatenation
  creating-an-array-using-nullable-values: Creating an array using nullable values
  ternary-operator: Ternary operator
---

# Null safe usage

Using property references that might be null in expressions can lead to unexpected results. This topic contains examples and how to handle them.

The examples in this topic use the following data model:

```json
{
  "user": {
    "name": {
      "given": "John",
      "family": "Doe"
    }
}
```

## String concatenation

* Issue

  Because `user.name.middle` is null, the expression `user.name.given + ', ' + user.name.middle + ', ' + user.name.family` returns `John, null, Doe`.

* Solution to concatenate only non-null values

  `#string.join({user.name.given, user.name.middle, user.name.family}, ', ')` returns `John, Doe`.

* Issue

  Because `user.age` is null and the other operand is numeric, the expression `3 + user.age` returns an error.

* Solution to avoid errors using an Elvis operator to add a default value

  `3 + (user.age ?: '')` returns `3`.

## Creating an array using nullable values

* Issue

  The newly created array `{user.externalId}` returns `[ null ]`.

* Solution to remove nulls from the newly created array

  `#data.removeAll({user.externalId}, {null})` returns `[]`.

## Ternary operator

* Issue

  Because `user.enabled` is null, the expression `user.enabled ? 'Active' : 'Inactive'` returns an error.

* Solution to avoid errors using an Elvis operator to add a default value

  `(user.enabled ?: false) ? 'Active' : 'Inactive'` returns `Inactive`.
