What is the fastest way to verify that a json[] array is not empty?
This is not returning a JSON Array,.

SELECT '{}'::json[]


The type json[] is not a "JSON Array", it's a SQL Array of type JSON. You should never be using this kind of structure. It's almost certainly a red flag of bad design.

What you want to check is that a Real JSON Array is not empty, you can do that with jsonb_array_length(jsonb). JSON is stored as JSON, or JSONB for binary json.

SELECT jsonb_array_length( '[]'::jsonb );


To see if it's empty,

SELECT jsonb_array_length( '[]'::jsonb ) = 0;


Warning, this just counts those elements, they may be null,

SELECT jsonb_array_length( '[null]'::jsonb );


So you may want to call jsonb_strip_nulls() on the array first.