Search code examples
jsonata

Jsonata predicate to filter objects without a specific property


Consider the following source data

[
  {
    "a": 1
  },
  {
    "a": 2,
    "b": 1
  }
]

Here's a query to filter objects that have a property b:

$[`b`]

It returns

{
  "a": 2,
  "b": 1
}

But how to get objects that HAVE NO property b?

Something like

$[$not(`b`)]

just give ** no match **

And I'm out of ideas (


Solution

  • Here is the simplest solution: $[$not($exists(b))]