title: How to search in a large JSON array and find records by multiple keys
body: <p>I have a very large dataset that's organized like this:</p>
  
  <pre><code>users = [
      {
          username: "Bill",
          gender: "Male",
          details: {
              city: "NY"
          }
      },
      {
          username: "Mary",
          gender: "Female",
          details: {
              city: "LA"
          }
      }
  ]
  </code></pre>
  
  <p>I need a quick way to search for multiple records by multiple values from multiple keys.</p>
  
  <p>I have dot-separated list of keys:</p>
  
  <pre><code>keys = ["gender", "details.city"]
  </code></pre>
  
  <p>I need to do something like this (written in pseudo code):</p>
  
  <pre><code>my_users = users.any? {|user|
    keys.each do |key|
      user.key == "NY"
    end
  }
  </code></pre>
  
  <p>I know this is not going to work. One of the reasons it will not work is that my list of keys is dot-separated, so I could either split it to an array of keys, as in <code>['gender']</code> and <code>['details']['city']</code>, or convert the user hash to a dot-separated object with a method like:</p>
  
  <pre><code>def to_o
    JSON.parse to_json, object_class: OpenStruct
  end
  </code></pre>