title: Looping through JSON with node.js
body: <p>I have a JSON file which I need to iterate over, as shown below...</p>
  
  <pre><code>{
      "device_id": "8020",
      "data": [{
          "Timestamp": "04-29-11 05:22:39 pm",
          "Start_Value":  0.02,
          "Abstract": 18.60,
          "Editor": 65.20
      }, {
          "Timestamp": "04-29-11 04:22:39 pm",
          "End_Value":  22.22,
          "Text": 8.65,
          "Common": 1.10,
          "Editable": "true",
          "Insert": 6.0
      }]
  }
  </code></pre>
  
  <p>The keys in data will not always be the same (i've just used examples, there are 20 different keys), and as such, I cannot set up my script to statically reference them to get the values.</p>
  
  <p>Otherwise I could state</p>
  
  <pre><code>var value1 = json.data.Timestamp;
  var value2 = json.data.Start_Value;
  var value3 = json.data.Abstract;
  etc
  </code></pre>
  
  <p>In the past i've used a simple foreach loop on the data node...</p>
  
  <pre><code>foreach ($json-&gt;data as $key =&gt; $val) {
      switch($key) {
          case 'Timestamp':
              //do this;
          case: 'Start_Value':
              //do this
      }
  }
  </code></pre>
  
  <p>But don't want to block the script. Any ideas?</p>