title: jq, when to use the dot and when not
body: <p>Consider <a href="https://gist.github.com/suntong/5d7d546c3ab075fb17c7693b4d3cc855" rel="noreferrer">the following <code>json</code> string</a>:</p>
  
  <pre><code>{
    "data": {
      "search": {
        "repositoryCount": 24,
        "edges": [
          {
            "node": {
              "name": "leumi-leumicard-bank-data-scraper",
              "url": "https://github.com/Urigo/leumi-leumicard-bank-data-scraper",
              "description": "Open bank data for Leumi bank and Leumi card credit card",
              . . . 
          },
          {
            "node": {
              "name": "puppeteer-demo",
              "url": "https://github.com/xJkit/puppeteer-demo",
              "description": "A demo for website scrapping by my puppet :&gt;",
              . . . 
  </code></pre>
  
  <p>If to use <code>jq</code> to select the <code>data</code>, then it needs a dot (<code>.</code>) before it. I.e.:</p>
  
  <pre><code>jq 'data' 
  jq: error: data/0 is not defined at &lt;top-level&gt;, line 1:
  data
  jq: 1 compile error
  </code></pre>
  
  <p>However <code>jq '.data'</code> works fine, and the selected data becomes:</p>
  
  <pre><code>{
    "search": {
      "repositoryCount": 24,
      "edges": [
        {
        ...
  </code></pre>
  
  <p>If to use <code>jq</code> to select the <code>search</code>, <em>after the pipe</em>, then it <em>does not</em> need a dot (<code>.</code>) before it. I.e.:</p>
  
  <pre><code>$ jq '.data | {.search} ' 
  jq: error: syntax error, unexpected FIELD (Unix shell quoting issues?) at &lt;top-level&gt;, line 1:
  .data | {.search}          
  jq: 1 compile error
  </code></pre>
  
  <p>However <code>jq '.data.search'</code> works fine. </p>
  
  <p>Moreover, a more complicated example, </p>
  
  <pre><code>jq '.data.search.edges[] | {node} '
  </code></pre>
  
  <p>works fine, but </p>
  
  <pre><code>jq '.data.search.edges[] | {node.name} '
  </code></pre>
  
  <p>gives:</p>
  
  <pre><code>jq: error: syntax error, unexpected FIELD, expecting '}' (Unix shell quoting issues?) at &lt;top-level&gt;, line 1:
  .data.search.edges[] | {node.name}                             
  jq: 1 compile error
  </code></pre>
  
  <p>So, all in all, I'm rather confused when to use the dot (<code>.</code>) and when not to, when using <code>jq</code>. Please help. Thx. </p>