Open
Description
Expected
root.text_objects = this.json_path("$.body[?(@.type==1)]")
# In: {"body":[{"type":1,"id":"foo"},{"type":2,"id":"bar"}]}
# Out: {"text_objects":[{"id":"foo","type":1}]}
Reference: https://www.benthos.dev/docs/guides/bloblang/methods/#examples-92
Actual
root.text_objects = this.json_path("$.body[?(@.type==1)]")
# In: {"body":[{"type":1,"id":"foo"},{"type":2,"id":"bar"}]}
# Out: {"text_objects":[]}
A curious behavior is that when using operators like >, <, >= or <=, the comparison works as expected:
root.text_objects = this.json_path("$.body[?(@.type>1)]")
# In: {"body":[{"type":1,"id":"foo"},{"type":2,"id":"bar"}]}
# Out: {"text_objects":[{"id":"bar","type":2}]}
So the current workaround for equality is to use >= && <=
root.text_objects = this.json_path("$.body[?(@.type>=1 && @.type<=1)]")
# In: {"body":[{"type":1,"id":"foo"},{"type":2,"id":"bar"}]}
# Out: {"text_objects":[{"id":"foo","type":1}]}