title: Convert json string value to number
body: <p>I have a JSON string that reads:</p>
  
  <pre><code>[{
      "id": "id2",
      "index": "2",
      "str": "str2",
      "cent": "200",
      "triplet": "222"
  },
  {
      "id": "id3",
      "index": "3",
      "str": "str3",
      "cent": "300",
      "triplet": "333"
  },
  {
      "id": "id4",
      "index": "4",
      "str": "str4",
      "cent": "400",
      "triplet": "444"
  },
  {
      "id": "id5",
      "index": "5",
      "str": "str5",
      "cent": "500",
      "triplet": "555"
  }]
  </code></pre>
  
  <p>The key-value pairs come dynamically from the server and I won't know beforehand what data to expect. 
  For a charting library that I use, I need the values in JSON to be numeric rather than string viz. <code>"index":2</code> instead of <code>"index":"2"</code>
  I am required to do this manipulation client-side using pure JS or jQuery.</p>
  
  <p>This was my approach but it doesn't seem to work:</p>
  
  <pre><code>var temp = //some json that I receive
  var jsonForChart = jQuery.extend(true, {}, temp);
  $.each(temp, function(key, value) {
      $.each(value, function(k, v) {
          if(!isNaN(v)){
              jsonForChart[key][k] = Number(v);
          }
      });
  });
  </code></pre>