title: How to get index of an object in JSON array?
body: <p>I have JSON array with the format below, how can I get the position (index) of an object using its key?</p>
  
  <pre><code>json = [
      {
          "id"=&gt;1, 
          "user_name"=&gt;"Mean Dean", 
          "user_profile_id"=&gt;"1", 
          "amount"=&gt;4
      },
      {
          "id"=&gt;2, 
          "user_name"=&gt;"Mad Stan", 
          "user_profile_id"=&gt;"2", 
          "amount"=&gt;7
      },
      {
          "id"=&gt;3, 
          "user_name"=&gt;"Jack Dean", 
          "user_profile_id"=&gt;"3", 
          "amount"=&gt;8
      }
  ]
  </code></pre>
  
  <p>For example how would I go about it if I wanted to get the position of the first element if I am given its id (in this case 1). I read about the <a href="https://apidock.com/ruby/Array/find_index" rel="nofollow noreferrer">index</a> method but don't know how to apply it to a JSON array.</p>
  
  <p>Thanks in advance for the help.</p>