title: Parse JSON file in ruby script and store specific value
body: <p>Parse the JSON file in Ruby script and obtain value for "key"</p>
  
  <p>My JSON file looks like</p>
  
  <pre><code>"terraform": [
      {
    "backend": [
      {
        "s3": [
          {
            "bucket": "terraform-dev",
            "dynamodb": "terraform_files",
            "encrypt": "true",
            "key": "Apple/Employee/Background/terraform.tfstate"
          }
        ]
       }
    ],
    "required_version": "~&gt; 0.11.8"
  }
  ] 
  </code></pre>
  
  <p>I tried writing this script in Ruby</p>
  
  <pre><code>#!/usr/bin/env ruby
  require "json"
  file = File.open "/Users/Test/conf.json"
  data = JSON.load file
  mykey= data['terraform'].first['backend']['s3']['key']
  print mykey
  file.close
  </code></pre>
  
  <p>Expected result: Apple/Employee/Background/terraform.tfstate</p>
  
  <p>Error Message: no implicit conversion of String into Integer (TypeError)</p>