How to query inside jsonb column
I have a column type of jsonb named changes
[[&quot;change&quot;,&quot;is_enabled&quot;,[false,true]]]


This is a terrible schema. You're essentially storing an array of arrays. And what you're asking is how to query a jsonb-array, for any elements that are themselves an array that happen to have an array after a string named &quot;is_enabled&quot; which inside the array, has an element of true.
test=# SELECT jsonb_pretty('[[&quot;change&quot;,&quot;is_enabled&quot;,[false,true]]]'::jsonb);
     jsonb_pretty      
-----------------------
 [                    +
     [                +
         &quot;change&quot;,    +
         &quot;is_enabled&quot;,+
         [            +
             false,   +
             true     +
         ]            +
     ]                +
 ]
(1 row)

That's going to be extremely ugly.  Nothing about this makes sense. Your JSON schema should just have one object that has {&quot;is_enabled&quot;:true}, or something like this {&quot;name&quot;:&quot;change&quot;,&quot;is_enable&quot;:true}. As is, you need something very ugly,
You can unnest both JSON array's getting to the inside with relative ease. Then you'll have to mark the row after the is_enabled element in the array,
SELECT *,
  '&quot;is_enabled&quot;'::jsonb = lag(j2) OVER (PARTITION BY j1 ORDER BY o) AS is_changed
FROM ( VALUES
  ($$[[&quot;change&quot;,&quot;is_enabled&quot;,[false,true]]]$$::jsonb)
) AS t(j)
CROSS JOIN LATERAL jsonb_array_elements(j)
  AS jae1(j1)
CROSS JOIN LATERAL jsonb_array_elements(j1) WITH ORDINALITY
  AS jae2(j2,o);
                     j                     |                   j1                    |      j2       | o | is_changed 
-------------------------------------------+-----------------------------------------+---------------+---+------------

 [[&quot;change&quot;, &quot;is_enabled&quot;, [false, true]]] | [&quot;change&quot;, &quot;is_enabled&quot;, [false, true]] | &quot;change&quot;      | 1 | 
 [[&quot;change&quot;, &quot;is_enabled&quot;, [false, true]]] | [&quot;change&quot;, &quot;is_enabled&quot;, [false, true]] | &quot;is_enabled&quot;  | 2 | f
 [[&quot;change&quot;, &quot;is_enabled&quot;, [false, true]]] | [&quot;change&quot;, &quot;is_enabled&quot;, [false, true]] | [false, true] | 3 | t
(3 rows)

From this, it's simple using bool_or, and another select
SELECT j, bool_or(j2 @&gt; 'true'::jsonb)
FROM (
  SELECT j, j2,
   '&quot;is_enabled&quot;'::jsonb = lag(j2) OVER (PARTITION BY j1 ORDER BY o) AS is_changed
  FROM ( VALUES
    ($$[[&quot;change&quot;,&quot;is_enabled&quot;,[false,true]]]$$::jsonb)
  ) AS t(j)
  CROSS JOIN LATERAL jsonb_array_elements(j)
    AS jae1(j1)
  CROSS JOIN LATERAL jsonb_array_elements(j1) WITH ORDINALITY
    AS jae2(j2,o)
) AS t
WHERE is_changed = true
GROUP BY j;

We can add more rows to the VALUES expression to test it
SELECT j, bool_or(j2 @&gt; 'true'::jsonb)
FROM (

  SELECT j, j2,
   '&quot;is_enabled&quot;'::jsonb = lag(j2) OVER (PARTITION BY j1 ORDER BY o) AS is_changed
  FROM ( VALUES
    ($$[[&quot;change&quot;,&quot;is_enabled&quot;,[false,false]]]$$::jsonb),
    ($$[[&quot;change&quot;,&quot;is_enabled&quot;,[true,false]]]$$::jsonb),
    ($$[[&quot;change&quot;,&quot;is_enabled&quot;,[true,true]]]$$::jsonb)
  ) AS t(j)
  CROSS JOIN LATERAL jsonb_array_elements(j)
    AS jae1(j1)
  CROSS JOIN LATERAL jsonb_array_elements(j1) WITH ORDINALITY
    AS jae2(j2,o)

) AS t
WHERE is_changed = true
GROUP BY j;

                     j                      | bool_or 
--------------------------------------------+---------
 [[&quot;change&quot;, &quot;is_enabled&quot;, [true, false]]]  | t
 [[&quot;change&quot;, &quot;is_enabled&quot;, [true, true]]]   | t
 [[&quot;change&quot;, &quot;is_enabled&quot;, [false, false]]] | f
(3 rows)

If you just want the ones where bool_or IS TRUE use HAVING..
WHERE is_changed = true
GROUP BY j
HAVING bool_or(j2 @&gt; 'true'::jsonb) IS TRUE;