title: What's the proper way to check if JSON has a key?
body: <p>I’m using Rails 4.2.3.  I have this code that is supposed to parse JSON</p>
  
  <pre><code>my_object_id = my_object.key?("id") ? my_object['id'] : nil
  </code></pre>
  
  <p>But when the “my_object” JSON is ‘[“name", "Info”]’, I get the below error</p>
  
  <pre><code>undefined method `key?' for ["name", "Info"]:Array
  </code></pre>
  
  <p>What’s the proper way check if my JSON is going to have an “id” key?</p>