title: Retrieving the first entity out of several ones
body: <p>I am a rank beginner with <code>jq</code>, and I've been going through the tutorial, but I think there is a conceptual difference I don't understand. A common problem I encounter is that a large JSON file will contain many objects, each of which is quite big, and I'd like to view the first complete object, to see which fields exist, what types, how much nesting, etc.</p>
  
  <p>In the <a href="https://stedolan.github.io/jq/tutorial/" rel="nofollow noreferrer">tutorial</a>, they do this:</p>
  
  <pre><code># We can use jq to extract just the first commit.
  $ curl 'https://api.github.com/repos/stedolan/jq/commits?per_page=5' | jq '.[0]'  
  </code></pre>
  
  <p>Here is an example with one object - here, I'd like to return the whole array (just like <code>my_array=['foo']; my_array[0]</code> would return <code>foo</code> in Python). </p>
  
  <pre><code>wget https://hacker-news.firebaseio.com/v0/item/8863.json
  </code></pre>
  
  <p>I can access and pretty-print the whole thing with <code>.</code></p>
  
  <pre><code>$ cat 8863.json | jq '.'
  $
  {
    "by": "dhouston",
    "descendants": 71,
    "id": 8863,
    "kids": [
      9224,
       ...
      8876
    ],
    "score": 104,
    "time": 1175714200,
    "title": "My YC app: Dropbox - Throw away your USB drive",
    "type": "story",
    "url": "http://www.getdropbox.com/u/2/screencast.html"
  }
  </code></pre>
  
  <p>But trying to get the first element fails:</p>
  
  <pre><code>$ cat 8863.json| jq '.[0]' 
  $ jq: error (at &lt;stdin&gt;:0): Cannot index object with number
  </code></pre>
  
  <p>I get the same error <code>jq '.[0]' 8863.json</code>, but strangely <code>echo 8863.json | jq '.[0]'</code> gives me <code>parse error: Invalid numeric literal at line 2, column 0</code>. What is the difference? Also, is this not the correct way to get the zeroth member of the JSON?</p>
  
  <p>I've looked at other SO posts with this error message and at the manual, but I'm still confused. I think of the file as an <em>array</em> of JSON objects, and I'd like to get the first. But it looks like <code>jq</code> works with something called a "stream", and does operations on all of it (say, return one given field from every object).</p>
  
  <h2>Clarification:</h2>
  
  <p>Let's say I have 2 objects in my JSON:</p>
  
  <pre><code>{
    "by": "pg",
    "id": 160705,
    "poll": 160704,
    "score": 335,
    "text": "Yes, ban them; I'm tired of seeing Valleywag stories on News.YC.",
    "time": 1207886576,
    "type": "pollopt"
  }
  {
    "by": "dpapathanasiou",
    "id": 16070,
    "kids": [
      16078
    ],
    "parent": 16069,
    "text": "Dividends don't mean that much: Microsoft in its dominant years (when they had 40%-plus margins and were raking in the cash) never paid a dividend (they did so only recently).",
    "time": 1177355133,
    "type": "comment"
  }
  </code></pre>
  
  <p>How would I get the entire first object (lines 1-9) with <code>jq</code>?</p>