'How do I do a contains expression in a nested object?

this is my json

{
  "items": [
      "top": {
        "first": "test",
        "second": {
          "third": "test",
        },
        ...

This returns all items where top.first contains test:

items[?contains(top.first, `test`)]

This returns an error:

items[?contains(top.second.third, `test`)]

TypeError: contains() expected argument 1 to be type (string | array) but received type null instead.

This works with a explict ==, but for some reason contains() is throwing the above error

items[?top.second.third == `test`]

How do I query one level lower here?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source