title: jq: Getting two levels of keys
body: <p>I have some json data that looks like:</p>
  
  <pre><code>{
    "p": {
      "d": {
        "a" : {
          "r": "foo",
          "g": 1
        },
        "b": {
          "r": "bar",
          "g": 2
        }
      },
      "c": {
        "e": {
          "r": "baz",
          "g": 1
        }
      },
      ...
    }
  }
  </code></pre>
  
  <p>I want something like:</p>
  
  <pre><code>{
    "d": [ 
      "a",
      "b"
    ],
    "c": [
      "e"
    ]
  }
  </code></pre>
  
  <p>I can get the list of keys on the first level under "p" with <code>jq '.p|keys'</code>, and the structure and keys on the second level with <code>jq '.p|map(.|keys)'</code>, but I can't figure out how to combine it.</p>