Has_value

This function can be used to evaluate if data $entry has a truthy value.

Syntax

bool has_value(any $entry)

This function will output “true” or “false” based on evaluation of $entry.

Parameters

$entry: The data to evaluate.

The following values are not truthy:

  • Null
  • “”
  • “false”
  • “null”
  • false
  • 0

In case the JSON path leads to an array, the array is not truthy if the array has 0 or ‘null’ elements.

Example

In this example, two values are evaluated. One results in a truthy, while the other does not.

{
    "Data1": ["a", "b", "c"],
    "Data2": null
}
{
    First: has_value(Data1),
    Second: has_value(Data2)
}
{
    "First": true,
    "Second": false
}

“First” results in true because “Data1” contains values in it’s array. “Second” results in false because it does not have a truthy value as according to the bulleted list above.