title: jQuery - Extract Data from JSON
body: <p>I have the following JSON feed:</p>
  
  <pre><code>{"mouldings":[{"moulding_id_2":{"cost":"3.1","width":45}},{"moulding_id_4":{"cost":"1.5","width":30}},{"moulding_id_6":{"cost":"2.1","width":50}}],"material_costs":[{"mountboard":{"cost":"0.00000246494303242769"}},{"glass":{"cost":"0.0000032426589803639"}},{"backing_board":{"cost":"0.00000135110790848496"}}],"app_options":[{"vat":{"value":"17.5"}},{"wastage":{"value":"20"}},{"markup":{"value":"3"}}]}
  </code></pre>
  
  <p>I am trying to extract the cost of a particular moulding using jQuery .getJSON. My jQuery code is as follows:</p>
  
  <pre><code>$.getJSON( '/calculate_quote/2,6,4.json', function (data) {
    alert(data.mouldings.moulding_id_2.cost);
  });
  </code></pre>
  
  <p>When this runs I get the following error:</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'cost' of undefined
  </code></pre>
  
  <p>Why am I getting this error, many thanks.</p>