not_null

Modified on Thu, 9 Jul at 10:50 AM

not_null

TABLE OF CONTENTS

Find first argument that is not null

Definition

any not_null(any *$argument [, any $...])

Returns the first argument that does not resolve to null. Accepts one or more arguments, and will evaluate them in order until a non-null argument is encountered. If all arguments' values resolve to null, then a value of null is returned.

Parameters

any *$argument

One or more arguments of any type, separated by comma.

Returns

any

The first argument provided that does not resolve to null.

Examples

Sample data
{
  "null1": null,
  "null2": null,
  "empty_array": [],
  "text": "alpha"
}
Transformation
{
  a: not_null(nonexistent, null1, null2, empty_array, text),
  b: not_null(null1, null2, `null`, text, empty_array),
  c: not_null(null1, null2)
}
Result
{
  "a": [],
  "b": "alpha",
  "c": null
}

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article