title: Postgres get json count over
body: <p>I have a column that contains a json object. My goal is to get the total number of the array even if I'm using limit.</p>
  
  <pre><code>CREATE TABLE json_values (
     elems json
  );
  
  INSERT INTO json_values VALUES ('{"field1" : [{"val" : 1}, {"val" : 2}, { "val" : 3}] ,"field2" : []}');
  
  
  SELECT json_array_elements(elems-&gt;'field1'), count(*) OVER()
  FROM json_values
  LIMIT 1
  </code></pre>
  
  <p>This displays the first row, but it seems that the count over() is not taken in consideration, indeed I get only 1 instead of 3.</p>
  
  <p>Is there another way to do it ?</p>