title: How to return distinct values in a JSON_ARRAYAGG
body: <p>So I'm attempting to place the results of a distinct, single-column query into a JSON array so it can be used on my web server.  I have it set up something like this:</p>
  
  <pre><code>SELECT JSON_OBJECT(
    'ArrayKey' VALUE JSON_ARRAYAGG( col ) 
  ) AS jsonResult
  FROM(SELECT DISTINCT column_name AS col
         FROM tbl_name);
  </code></pre>
  
  <p>However, when this query returns results, the array it generates in JSON contains all values from my column and ignores the DISTINCT clause in the subquery somehow.  Whenever I get rid of the JSON_ARRAYAGG clause and output the results directly, the result are unique, but somehow the command is ignored when I add it back in.  I've also attempted to place the DISTINCT clause inside the JSON_ARRAYAGG as well, like so:</p>
  
  <pre><code>SELECT JSON_OBJECT(
    'ArrayKey' VALUE JSON_ARRAYAGG( DISTINCT col ) 
  ) AS jsonResult
  FROM(SELECT DISTINCT column_name AS col
         FROM tbl_name);
  </code></pre>
  
  <p>to no avail.  Does anyone know what's going wrong in my code that's causing the array to output all values instead of distinct ones?</p>