title: Javascript Object notation with variable
body: <p>My PHP script specs.php outputs the following:</p>
  
  <pre><code>{
      "hd": {
          "dimensions": [
              "1920x1080",
              "1920x1080",
              "1920x1080" 
          ],
          "sizes": [
              "603 KB",
              "265 KB",
              "438 KB" 
          ] 
      },
      "medium": {
          "dimensions": [
              "800x530",
              "800x530",
              "800x530" 
          ],
          "sizes": [
              "198 KB",
              "105 KB",
              "152 KB" 
          ] 
      },
      "status": "success"
  }
  </code></pre>
  
  <p>With jQuery I load in the JSON and assign it to specs_obj<br />
  I can access the first item's "medium" "sizes" with specs_obj. medium.sizes[0]<br />
  How can I use a variable in the dot notation?</p>
  
  <pre><code>var specs_obj;
  $.post("specs.php", {},
      function(data) {
          if (data.status == "success") {
                  specs_obj = data;
                  writeSizes("medium");
          } else {}
      }, "json"
  );
  
  function writeSizes(preset) {
      // test get medium dimensions from first file
      var size = specs_obj. medium.sizes[0];
      // var size = specs_obj.preset.sizes[0];
  }
  </code></pre>