title: How to get all keys with values from nested objects
body: <p>I'm looking for something kind of like <code>Object.keys</code> but that works for potentially nested objects. It also shouldn't include keys that have object/array values (it should only include keys with immediate string/number/boolean values).</p>
  
  <h1>Example A</h1>
  
  <h2>Input</h2>
  
  <pre><code>{
     "check_id":12345,
     "check_name":"Name of HTTP check",
     "check_type":"HTTP"
  }
  </code></pre>
  
  <h2>Expected output</h2>
  
  <pre class="lang-js prettyprint-override"><code>[
    "check_id",
    "check_name",
    "check_type"
  ]
  </code></pre>
  
  <p><code>Object.keys</code> would work for flat cases like this, but not for nested cases:</p>
  
  <h1>Example B</h1>
  
  <h2>Input</h2>
  
  <pre class="lang-js prettyprint-override"><code>{
     "check_id":12345,
     "check_name":"Name of HTTP check",
     "check_type":"HTTP",
     "tags":[
       "example_tag"
     ],
     "check_params":{
        "basic_auth":false,
        "params":[
          "size"
        ],
        "encryption": {
          "enabled": true,
        }
     }
  }
  </code></pre>
  
  <h2>Expected output</h2>
  
  <pre class="lang-js prettyprint-override"><code>[
    "check_id",
    "check_name",
    "check_type",
    "check_params.basic_auth",
    "check_params.encryption.enabled"
  ]
  </code></pre>
  
  <p>Note that this does not include <code>tags</code>, <code>check_params</code>, <code>check_params.params</code>, or <code>check_params.encryption</code> since these values are arrays/objects.</p>
  
  <h1>The question</h1>
  
  <p>Is there a library that does this? How would you implement it so that it can work with any object, large and nested, or small?</p>