Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

{
  "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))]

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading