Let's say we have a table items which has columns name and attributes:
CREATE TABLE students (
name VARCHAR(100),
attributes JSON
)
where attributes is an array of (always equally-structured) JSON documents such as
[{"name":"Attribute 1","value":"Value 1"},{"name":"Attribute 2","value":"Value 2"}]
I now want to find all students where any attribute value matches something (such as Foo%). Here's a playground example.
I realize that this isn't exactly the most straight-forward design, but for now it's what I have to work with, though performance of such a search being categorically terribly inefficient would of course be a valid concern.
json[]never makes sense. It's better to store a "real" JSON array inside ajsoncolumn.