title: JQ: Filtering for keys
body: <p>I'm trying to use the JQ command to filter a json object to selectively extract keys.  Here's a sample object that I've placed in file x.txt:</p>
  <pre><code>{
    &quot;activities&quot; : {
  
      &quot;-KSndgjqvmQkWVKHCpLh&quot; : {
        &quot;create_device&quot; : &quot;...&quot;,
        &quot;stop_time_utc&quot; : &quot;2016-11-01T23:08:08Z&quot;
      },
  
      &quot;-KSoBSrBh6PZcjRocGD7&quot; : {
        &quot;create_device&quot; : &quot;...&quot;
      },
  
      &quot;-KSptboGjo8g4bieUbGM&quot; : {
        &quot;create_device&quot; : &quot;...&quot;,
        &quot;stop_time_utc&quot; : &quot;2017-01-17T23:08:08Z&quot;
      }
  
    }
  }
  </code></pre>
  <p>The following command can extract all of the activity keys:</p>
  <pre><code>cat x.txt | jq '.activities | keys'
  [
    &quot;-KSndgjqvmQkWVKHCpLh&quot;,
    &quot;-KSoBSrBh6PZcjRocGD7&quot;,
    &quot;-KSptboGjo8g4bieUbGM&quot;
  ]
  </code></pre>
  <p>I've been googling and experimenting for a few hours trying to filter the object to select only the activity entries that have a stop_time_utc value, and use something like a &quot;select(.stop_time_utc | fromdateiso8601 &gt; now)&quot; to only pick activities that have expired. For example, I'd like to use filters to create an array from the sample object with only the one relevant entry:</p>
  <pre><code>[
    &quot;-KSndgjqvmQkWVKHCpLh&quot;
  ]
  </code></pre>
  <p>Is attempting this with the keys option the wrong route?  Any ideas or suggestions would be much appreciated.</p>