Search code examples
jsonata

how to get objects which param contains substring in value using JSONata?


here is data:

[
  {name:"Hello"},
  {name:"World"},
  {name:"Hello World"}
]

how to build proper JSONata query to get all entries where name contains World?

I did try the "'World' in name", but it returns undefined

Thanks.


Solution

  • Use the $contains() function within a filter expression ($[...] filters the input array):

    $[$contains(name, "World")]
    

    See this in the JSONata Exerciser: http://try.jsonata.org/BJDPGXzEG