title: Using jq to extract specific property values and output on a single line
body: <p>I've this ElasticSearch snapshot output and would like to reduce it to print, on a single line, from each <code>snapshot</code> the values of the  <code>end_time_in_millis</code> and <code>snapshot</code> property separate by a space:</p>
  
  <pre><code>1429609790767 snapshot_1
  1429681169896 snapshot_2
  </code></pre>
  
  <p>Basically the output of</p>
  
  <ul>
  <li><code>cat  data | jq '.snapshots[].end_time_in_millis'</code> and</li>
  <li><code>cat  data | jq '.snapshots[].snapshot'</code></li>
  </ul>
  
  <p>but combined on one line.</p>
  
  <p>I was looking at <code>map</code> but couldn't make out how to apply it; also reading <a href="https://stackoverflow.com/questions/29259249/extracting-selected-properties-from-a-nested-json-object-with-jq">this answer</a> I tried:</p>
  
  <pre><code>cat data  | jq '.snapshots[] | map(. |= with_entries( select( .key == ( "snapshot") ) ) )'
  </code></pre>
  
  <p>But that produces lots of errors and <code>null</code> output.</p>
  
  <p>The data:</p>
  
  <pre><code>{
    "snapshots": [
      {
        "shards": {
          "successful": 1,
          "failed": 0,
          "total": 1
        },
        "failures": [],
        "snapshot": "snapshot_1",
        "indices": [
          "myindex1"
        ],
        "state": "SUCCESS",
        "start_time": "2015-04-21T09:45:47.041Z",
        "start_time_in_millis": 1429609547041,
        "end_time": "2015-04-21T09:49:50.767Z",
        "end_time_in_millis": 1429609790767,
        "duration_in_millis": 243726
      },
      {
        "shards": {
          "successful": 1,
          "failed": 0,
          "total": 1
        },
        "failures": [],
        "snapshot": "snapshot_2",
        "indices": [
          "myindex1"
        ],
        "state": "SUCCESS",
        "start_time": "2015-04-22T05:36:02.333Z",
        "start_time_in_millis": 1429680962333,
        "end_time": "2015-04-22T05:39:29.896Z",
        "end_time_in_millis": 1429681169896,
        "duration_in_millis": 207563
      }
    ]
  }
  </code></pre>