postgresql: mapping json array to string array
Don't aggregate the whole row, just aggregate the column:
SELECT json_agg(invoice_number) 
FROM 
(
  SELECT DISTINCT invoice_number 
  FROM sale.invoice_item 
  WHERE product_id = ANY(_product_ids)
) record

Or even simpler:
SELECT json_agg(DISTINCT invoice_number)
FROM sale.invoice_item 
WHERE product_id = ANY(_product_ids)