title: Ruby- extract a value inside a nested json
body: <p>I am trying to retrieve the thumbnail for a video insdie a json sent by facebook</p>
  
  <p>If I do in ruby</p>
  
  <pre><code>address = 'https://graph.facebook.com/v2.12/936915709799694/thumbnails?access_token=EAACEdEose0cBAIEEedXcwXMsqusqhdudsqhusdqhsduhdsudshudshudsds'
  example = Net::HTTP.get(URI.parse(address))
  </code></pre>
  
  <p>I get an escaped version of the following json (note that there is only one key data which then is an array of jsons)</p>
  
  <pre><code>{
    "data": [
      {
        "id": "936918379799427",
        "height": 720,
        "scale": 1,
        "uri": "https://scontent.xx.fbcdn.net/v/t15.0-10/27853051_936918406466091_6621898933939470336_n.jpg?oh=1b4afa6cfca7030b98915e12ab85cf70&amp;oe=5B1CFCFA",
        "width": 1280,
        "is_preferred": false
      },
      {
        "id": "936918369799428",
        "height": 720,
        "scale": 1,
        "uri": "https://scontent.xx.fbcdn.net/v/t15.0-10/27260162_936918416466090_2202441332260077568_n.jpg?oh=894848d7069f27010c055757e3449ec1&amp;oe=5B228409",
        "width": 1280,
        "is_preferred": false
      },
      {
        "id": "936918376466094",
        "height": 720,
        "scale": 1,
        "uri": "https://scontent.xx.fbcdn.net/v/t15.0-10/27415107_936918419799423_2695587454257201152_n.jpg?oh=f1f03e6b754cb9365dd7319d6a72c401&amp;oe=5B1C02A1",
        "width": 1280,
        "is_preferred": false
      },
      {
        "id": "936918373132761",
        "height": 720,
        "scale": 1,
        "uri": "https://scontent.xx.fbcdn.net/v/t15.0-10/27410300_936918423132756_1211957161530228736_n.jpg?oh=3c52834d0148e52ec4d6b30df7d18725&amp;oe=5B17CFCA",
        "width": 1280,
        "is_preferred": true
      },
      {
        "id": "936918383132760",
        "height": 720,
        "scale": 1,
        "uri": "https://scontent.xx.fbcdn.net/v/t15.0-10/27596995_936918429799422_8351220412767535104_n.jpg?oh=e4bc154cd5a5bfff72934516aeb36c43&amp;oe=5B1841C0",
        "width": 1280,
        "is_preferred": false
      }
    ]
   }
  </code></pre>
  
  <p>I would like to grab the json where is_preferred=true then extract the uri inside this json</p>
  
  <p>so in the above example, the correct json piece would be</p>
  
  <pre><code>{
        "id": "936918373132761",
        "height": 720,
        "scale": 1,
        "uri": "https://scontent.xx.fbcdn.net/v/t15.0-10/27410300_936918423132756_1211957161530228736_n.jpg?oh=3c52834d0148e52ec4d6b30df7d18725&amp;oe=5B17CFCA",
        "width": 1280,
        "is_preferred": true
      }
  </code></pre>
  
  <p>and the uri to retrieve would be </p>
  
  <pre><code>https://scontent.xx.fbcdn.net/v/t15.0-10/27410300_936918423132756_1211957161530228736_n.jpg?oh=3c52834d0148e52ec4d6b30df7d18725&amp;oe=5B17CFCA
  </code></pre>