title: Write value from a json array to javascript variable
body: <p>How can i make make a variable in a javascript and give it a value from an json array?</p>
  
  <p>The array is sent from a php script and looks like this:</p>
  
  <pre><code>php
  
  $stat = array("v1" =&gt; "$v1", "v2" =&gt; "$v2", "v3" =&gt; "$v3",
  "v4" =&gt; "$v4", "v5" =&gt; "$v5", "pump" =&gt; "$pump", "flow" =&gt; "$flow");
  echo json_encode(($stat));
  
  html/javascript
  
  $.ajaxSetup({ cache: false });
  setInterval(function(){
  $.getJSON('statusdata.php',function(data) {
  $.each(data, function(key, val) {
  
  // I try to do something like this..
  var v1 = key[1];
  var v2 = key[2];
  and so on..
  </code></pre>
  
  <p>Then i want to use a variable to alert a popup-window with some kind of warning.</p>
  
  <p>Someting like:</p>
  
  <pre><code>if (v1 == 1){
  run the popup function!
  }
  </code></pre>
  
  <p>Can anyone help me?</p>