title: Retrieve first N records of a JSON array with a Postgresql query
body: <p>PostgreSQL has some native <a href="https://www.postgresql.org/docs/9.3/static/functions-json.html" rel="noreferrer">JSON operations</a> since verison 9.3. Suppose you have a table, <code>my_table</code>, with a <code>json</code> column, <code>my_json_col</code>, structured as follows:</p>
  
  <pre><code>[
    { "id": 1, "some_field": "blabla" },
    { "id": 2, "some_field": "foo" }
    ...
  ]
  </code></pre>
  
  <p>To retrieve the n-th element of <code>my_json_col</code>, you would execute something like: <code>SELECT my_json_col-&gt;n FROM my_table WHERE ...</code>. So if <code>n = 1</code>, the query would return the <code>"id": 2</code> record in my example.</p>
  
  <p>I want to retrieve the first n elements, e.g. if <code>n = 2</code> the query should return the first two records in my example. Is this possible?</p>