title: How do I safely parse data from a Ruby Hash?
body: <p>I'm parsing a JSON result into a Ruby hash. The JSON result looks like this:</p>
  
  <pre><code>{
    "records": [
      {
        "recordName": "7DBC4FAD-D18C-476A-89FB-14A515098F34",
        "recordType": "Media",
        "fields": {
          "data": {
            "value": {
              "fileChecksum": "ABCDEFGHIJ",
              "size": 9633842,
              "downloadURL": "https://cvws.icloud-content.com/B/ABCDEF"
            },
            "type": "ASSETID"
          }
        },
        "recordChangeTag": "ii23box2",
        "created": {
          "timestamp": 1449863552482,
          "userRecordName": "_abcdef",
          "deviceID": "12345"
        },
        "modified": {
          "timestamp": 1449863552482,
          "userRecordName": "_abcdef",
          "deviceID": "12345"
        }
      }
    ]
  }
  </code></pre>
  
  <p>I can't guarantee that it'll return with any/all those values, or that each value will be of a certain type (e.g. Array, Hash, string, number), and if I call it incorrectly then I get a crash.</p>
  
  <p>Right now I need the downloadURL for the first item in the 'records' array, or to write it as I might with the Swift library SwiftyJSON (which I'm far more familiar with):</p>
  
  <pre><code>json["records"][0]["fields"]["data"]["value"]["downloadURL"]
  </code></pre>
  
  <p>I'm wondering what the safest/best/standard way to do this safely in Ruby is. Perhaps I'm thinking about it wrong?</p>